Export (0) Print
Expand All

IDbSetExtensions.AddOrUpdate(Of TEntity) Method (IDbSet(Of 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)

<ExtensionAttribute> _
Public Shared Sub AddOrUpdate(Of TEntity As Class) ( _
	set As IDbSet(Of TEntity), _
	ParamArray entities As TEntity() _
Dim set As IDbSet(Of TEntity)
Dim entities As TEntity()


Type Parameters


The type of the Entity.


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

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

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(Of 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(Of TEntity) implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.

© 2015 Microsoft