简体   繁体   English

从数据库更新模型时出错(EntityFramework数据库优先)

[英]Error in Updating the model from database (EntityFramework Database-First)

I know the reason for the following error very well, 我非常了解以下错误的原因,

The specified type member 'Ticket' is not supported in LINQ to Entities. LINQ to Entities不支持指定的类型成员'Ticket'。 Only initializers, entity members, and entity navigation properties are supported. 仅支持初始化程序,实体成员和实体导航属性。

but the problem is that the property 'Ticket' is not calculated property or anything else, it is a normal field in the database, I am trying to read it. 但是问题在于属性“ Ticket”不是计算属性或其他任何属性,它是数据库中的普通字段,我正在尝试读取它。

I am using Database-first and the model was working in a wonderful way, but after I added this property to the database and "Update the Model from database" I started to receive this error? 我正在使用数据库优先模式,并且该模型以一种很棒的方式工作,但是在将此属性添加到数据库并“从数据库更新模型”之后,我开始收到此错误吗?

What I missed in the "Update the Model from database" to deserve this problem? 我应该在“从数据库更新模型”中错过什么来解决这个问题?

Just in case someone faced the same problem. 以防万一有人遇到同样的问题。 My problem was in the connection string 我的问题出在连接字符串中

<add name="BT_IQMSEntities" connectionString="metadata=res://*/BT_IQMSEntities.csdl|res://*/BT_IQMSEntities.csdl|res://*/BT_IQMSEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=biteg-data;initial catalog=BT_IQMS;user id=sa;password=IWillNotShowYouMyPassword;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Actually, the problem was in the three section 实际上,问题出在三个部分
BT_IQMSEntities.csdl
BT_IQMSEntities.csdl
BT_IQMSEntities.msl
those sections must be the same as the name of the .edmx, and in my case the names where different from the .edmx name, and after fixing them and make them all the same, the problem solved. 这些部分必须与.edmx的名称相同,并且在我的情况下,这些名称必须与.edmx的名称不同,并且在将它们固定并使其完全相同之后,问题得以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM