当我像这样使用Migration类中的方法时:
DbSet<T>.AddOrUpdate( new Instance(){});该方法只生成insert T-SQL,我收到一个异常,因为该行已经存在于表中。
Migration类中的滑动方法如下所示:
DbSet<T>.AddOrUpdate( p=>p.name,new Instance(){}): 我不能以我的方式转换它(表有一个连接索引(Column1,Column2))。
现在我的问题是:如何使用该方法
public static void AddOrUpdate<TEntity>(
this IDbSet<TEntity> set,
Expression<Func<TEntity, Object>> identifierExpression,
params TEntity[] entities
)where TEntity : class必须在表的两列中定义参数identifierExpression I,以确定应执行添加操作还是更新操作
发布于 2016-09-19 17:44:03
使用此语句将解决一个问题,因为它不能索引您的列。
DbSet<T>.AddOrUpdate( new Instance(){});你是否应该使用下面的代码:
context.People.AddOrUpdate(p => new { p.FirstName, p.LastName }, people);https://stackoverflow.com/questions/39569708
复制相似问题