Table of Contents

Class IdentityHelpers

Namespace
SunamoMsSqlServer.Helpers
Assembly
SunamoMsSqlServer.dll

Provides extension methods for managing SQL Server IDENTITY_INSERT on Entity Framework Core DbContext.

public static class IdentityHelpers
Inheritance
IdentityHelpers
Inherited Members

Methods

DisableIdentityInsert<T>(DbContext)

Disables IDENTITY_INSERT for the specified entity type.

public static Task DisableIdentityInsert<T>(this DbContext context)

Parameters

context DbContext

The DbContext instance used to execute the command.

Returns

Task

A task representing the asynchronous operation.

Type Parameters

T

The entity type mapped to the target table.

EnableIdentityInsert<T>(DbContext)

Enables IDENTITY_INSERT for the specified entity type.

public static Task EnableIdentityInsert<T>(this DbContext context)

Parameters

context DbContext

The DbContext instance used to execute the command.

Returns

Task

A task representing the asynchronous operation.

Type Parameters

T

The entity type mapped to the target table.

SaveChangesWithIdentityInsertAsync<T>(DbContext)

Asynchronously saves changes with IDENTITY_INSERT enabled for the specified entity type within a transaction.

public static Task SaveChangesWithIdentityInsertAsync<T>(this DbContext context)

Parameters

context DbContext

The DbContext instance used to execute the command.

Returns

Task

A task representing the asynchronous operation.

Type Parameters

T

The entity type mapped to the target table.

SaveChangesWithIdentityInsert<T>(DbContext)

Saves changes with IDENTITY_INSERT enabled for the specified entity type within a transaction.

[Obsolete("You may need to modify the method so that async methods run correctly.")]
public static void SaveChangesWithIdentityInsert<T>(this DbContext context)

Parameters

context DbContext

The DbContext instance used to execute the command.

Type Parameters

T

The entity type mapped to the target table.