dbnull mysql_MySQL-实体:表'TableDetails'中列'IsPrimaryKey'的值为DBNull

我将 Visual Studio 2013 与 Entity Framework 5 和M ySQL Server

5.7.9结合使用 。

尝试从数据库创建模型( 或“从数据库更新模型” )时,出现以下消息:

‘System.Data.StrongTypingException:表’TableDetails’中’IsPrimaryKey’列的值为DBNull。-–>

System.InvalidCastException:指定的强制转换无效。

我知道这个问题已经被问过了,但是我没有找到任何解决方案。我也没有降级到MySQL 5.6的选择。

即使对于简单的表,也会出现此问题。

样品表

CREATE TABLE new_table

(

id int(11) NOT NULL AUTO_INCREMENT,

name varchar(45) NOT NULL,

PRIMARY KEY (id)

)

ENGINE = InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

如果表仅由“主键”组成,则将按原样创建模型。

编辑: 如果我使两个字段主键都将创建该模型而没有任何错误。

有人对此有任何想法吗?

亲切的问候。

完整的错误堆栈:

由于以下异常而无法生成模型:’System.Data.StrongTypingException:表’TableDetails’中列’IsPrimaryKey’的值为DBNull。-–>

System.InvalidCastException:指定的强制转换无效。在Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.TableDetailsRow.get_IsPrimaryKey()-内部异常堆栈跟踪的结尾-

在Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.TableDetailsRow.get_IsPrimaryKey

(),位于Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateProperties(IList

1 columns, IList1错误,列表1& keyColumns, List1和排除的列,列表1&

invalidKeyTypeColumns) at

Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntityType(IList列1,布尔逻辑needsDefiningQuery)在Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets(IEnumerable的1

tableDetailsRows, EntityRegister entityRegister,

IList在Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets

1个entitySetsForReadOnlyEntityTypes,DbObjectType的objectType)(IEnumerable的1

tableDetailsRowsForTables, IEnumerable1个tableDetailsRowsForViews

,在Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.Build(StoreSchemaDetails

storeSchemaDetails)处的Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()处的EntityRegister

EntityRegister)

.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(列表1

errors) at

Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String

storeModelNamespace,

List1错误),位于Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(EdmxHelper

edmxHelper)”。从数据库加载元数据花费了00:00:00.5856317。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值