且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将类型“System.Data.EntityState”隐式转换为“System.Data.Entity.EntityState”。存在显式转换(您是否丢失了一个转换)?

更新时间:2023-02-24 19:27:19

当您使用EF 6或从EF 5移动到EF 6时,应使用 System.Data.Entity。 EntityState 而不是 System.Data.EntityState 。当您的项目引用EF6但您有EF5的代码时,会发生此错误。

When you are using EF 6 or moving from EF 5 to EF 6, you should use System.Data.Entity.EntityState instead of System.Data.EntityState. This error happens when your project has reference to EF6 but you have code for EF5.

另外,请检查此链接:当从EF5升级到EF6时,应该替换System.Data.Objects?

Also, check this link: When upgrading from EF5 to EF6 should I replace System.Data.Objects?.