Export (0) Print
Expand All

IDbSetExtensions.AddOrUpdate(TEntity) Method (IDbSet(TEntity), TEntity[])

Entity Framework 5.0

Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can be useful when seeding data using Migrations.

Namespace:  System.Data.Entity.Migrations
Assembly:  EntityFramework (in EntityFramework.dll)

static member AddOrUpdate : 
        set:IDbSet<'TEntity> * 
        entities:'TEntity[] -> unit   when 'TEntity : not struct

Type Parameters

TEntity

The type of the Entity.

Parameters

set
Type: System.Data.Entity.IDbSet(TEntity)

An IDbSet(TEntity) object that is used to perform create, read, update, and delete operations.

entities
Type: TEntity[]

The entities to add or update.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IDbSet(TEntity). When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=vs.103).aspx or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.103).aspx.

When the set parameter is a custom or fake IDbSet(TEntity) implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.

Show:
© 2015 Microsoft