mysql中更改数据库后,在项目中根据数据库更新EF模型,有时候会报错:
'System.Data.StrongTypingException: The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull . ---> System.InvalidCastException: Specified cast is not valid.
解决方法:
1、进入mysql控制台
在CMD中进入mysql.exe所在目录。
执行mysql -uroot -p123456(root为mysql登录账号,123456位登录密码)。
2、打开数据库
执行use test(test为数据库名称)
3、执行命令:set global optimizer_switch=’derived_merge=OFF’
4、更新EF中的整个.edmx文件