Entity framework 如何在Entity Framework 4.4中实现DBSet.AddOrUpdate?
为了回答Slauma对我的问题的回答,我将我的应用程序从Entity Framework 5.0转换回使用Entity Framework 5.0和target Framework.NET 4.0(也称为Entity Framework 4.4)Entity framework 如何在Entity Framework 4.4中实现DBSet.AddOrUpdate?,entity-framework,code-first,Entity Framework,Code First,为了回答Slauma对我的问题的回答,我将我的应用程序从Entity Framework 5.0转换回使用Entity Framework 5.0和target Framework.NET 4.0(也称为Entity Framework 4.4) // You can use the DbSet<T>.AddOrUpdate() helper extension method 然而,我遇到了以下错误 System.Data.Entity.DbSet<MyEntity>
// You can use the DbSet<T>.AddOrUpdate() helper extension method
然而,我遇到了以下错误
System.Data.Entity.DbSet<MyEntity> does not contain a definition for AddOrUpdate
and no extension method of a type System.Data.Entity.DbSet<MyEntity> accepting a
first argument of type System.Data.Entity.DbSet<MyEntity> could be found.
(Are you missing a using directive or assembly reference )
// You can use the DbSet<T>.AddOrUpdate() helper extension method
System.Data.Entity.DbSet不包含AddOrUpdate的定义
并且没有接受
可以找到System.Data.Entity.DbSet类型的第一个参数。
(是否缺少using指令或程序集引用)
我曾尝试搜索此错误消息的片段,但没有取得多大成功。
奇怪的是,4.4甚至没有被提及,EF4.4甚至没有SO标签,您必须添加
using System.Data.Entity.Migrations;
// You can use the DbSet<T>.AddOrUpdate() helper extension method
…添加到您的代码文件中,以使添加或更新
可用。它是一个在System.Data.Entity.Migrations
命名空间中的IDbSetExtensions
类中实现的类。对于MVC5 web应用程序,您会在配置的种子方法中得到以下注释:
// You can use the DbSet<T>.AddOrUpdate() helper extension method