Share via


Database.SetInitializer<TContext> Method

Definition

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>.

public static void SetInitializer<TContext> (System.Data.Entity.IDatabaseInitializer<TContext> strategy) where TContext : System.Data.Entity.DbContext;
static member SetInitializer : System.Data.Entity.IDatabaseInitializer<'Context (requires 'Context :> System.Data.Entity.DbContext)> -> unit (requires 'Context :> System.Data.Entity.DbContext)
Public Shared Sub SetInitializer(Of TContext As DbContext) (strategy As IDatabaseInitializer(Of TContext))

Type Parameters

TContext

The type of the context.

Parameters

strategy
IDatabaseInitializer<TContext>

The initializer to use, or null to disable initialization for the given context type.

Applies to