Export (0) Print
Expand All

Database.SetInitializer<TContext> Method

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

Sets the database initializer to use for the given context type. The database initializer is called when a the given DbContext type is used to access a database for the first time. The default strategy for Code First contexts is an instance of CreateDatabaseIfNotExists<TContext>.

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

public static void SetInitializer<TContext>(
	IDatabaseInitializer<TContext> strategy
)
where TContext : DbContext

Type Parameters

TContext

The type of the context.

Parameters

strategy
Type: System.Data.Entity.IDatabaseInitializer<TContext>
The initializer to use, or null to disable initialization for the given context type.
Show:
© 2015 Microsoft