1. 程式人生 > >EF連線Mysql 表'TableDetails'中的列'IsPrimaryKey'的值為DBNull

EF連線Mysql 表'TableDetails'中的列'IsPrimaryKey'的值為DBNull

無法生成模型,因為存在以下異常:'System.Data.StrongTypingException:表'TableDetails'中的列'IsPrimaryKey'的值為DBNull。---> System.InvalidCastException:指定的轉換無效。

原文連結http://stackoverflow.com/questions/33575109/mysql-entity-the-value-for-column-isprimarykey-in-table-tabledetails-is

 原文:

Entity Framework (version 6.1.3) and MySQL Server (>= 5.7.6)

One way to resolve the issue is,

1. Open Services (services.msc) and restart MySQL57 service.   
2. Execute the following commands in MySQL.
   use <<database name>>;
   set global optimizer_switch='derived_merge=OFF';
3. Update the .edmx.

It's a late reply. But hope it will help somebody.

Thanks.

 大致翻譯:

1.重新啟動mysql服務

2.開啟命令列介面

set global optimizer_switch='derived_merge=OFF';

重新啟動mysql服務

3.重新新建EF或者更新等操作

親測可用。