DbSetMigrationsExtensions.AddOrUpdate Method
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() ![]() | AddOrUpdate<TEntity>(IDbSet<TEntity>, TEntity[]) | Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations. |
![]() ![]() | AddOrUpdate<TEntity>(IDbSet<TEntity>, Expression<Func<TEntity, Object>>, TEntity[]) | Adds or updates entities by a custom identification expression when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations. |
DbSetMigrationsExtensions.AddOrUpdate<TEntity> Method (IDbSet<TEntity>, TEntity[])
Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations.
public static void AddOrUpdate<TEntity>( this IDbSet<TEntity> set, params TEntity[] entities ) where TEntity : class
Parameters
- set
-
Type:
System.Data.Entity.IDbSet<TEntity>
The set to which the entities belong.
- entities
-
Type:
TEntity[]
The entities to add or update.
Type Parameters
- TEntity
The type of entities to add or update.
When the set parameter is a custom or fake IDbSet implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.
DbSetMigrationsExtensions.AddOrUpdate<TEntity> Method (IDbSet<TEntity>, Expression<Func<TEntity, Object>>, TEntity[])
Adds or updates entities by a custom identification expression when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations.
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public static void AddOrUpdate<TEntity>( this IDbSet<TEntity> set, Expression<Func<TEntity, object>> identifierExpression, params TEntity[] entities ) where TEntity : class
Parameters
- set
-
Type:
System.Data.Entity.IDbSet<TEntity>
The set to which the entities belong.
- identifierExpression
-
Type:
System.Linq.Expressions.Expression<Func<TEntity, Object>>
An expression specifying the properties that should be used when determining whether an Add or Update operation should be performed.
- entities
-
Type:
TEntity[]
The entities to add or update.
Type Parameters
- TEntity
The type of entities to add or update.
When the set parameter is a custom or fake IDbSet implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.