DropCreateDatabaseIfModelChanges<TContext> DropCreateDatabaseIfModelChanges<TContext> DropCreateDatabaseIfModelChanges<TContext> Class

Definition

An implementation of IDatabaseInitializer that will DELETE, recreate, and optionally re-seed the database only if the model has changed since the database was created.

public class DropCreateDatabaseIfModelChanges<TContext> : System.Data.Entity.IDatabaseInitializer<TContext> where TContext : DbContext
type DropCreateDatabaseIfModelChanges<'Context (requires 'Context :> DbContext)> = class
    interface IDatabaseInitializer<'Context (requires 'Context :> DbContext)>
Public Class DropCreateDatabaseIfModelChanges(Of TContext)
Implements IDatabaseInitializer(Of TContext)

Type Parameters

TContext

The type of the context.

Inheritance
DropCreateDatabaseIfModelChanges<TContext>DropCreateDatabaseIfModelChanges<TContext>DropCreateDatabaseIfModelChanges<TContext>
Implements

Remarks

Whether or not the model has changed is determined by the CompatibleWithModel(Boolean) method. To seed the database create a derived class and override the Seed method.

Constructors

DropCreateDatabaseIfModelChanges<TContext>() DropCreateDatabaseIfModelChanges<TContext>() DropCreateDatabaseIfModelChanges<TContext>()

Initializes a new instance of the DropCreateDatabaseIfModelChanges<TContext> class.

Methods

InitializeDatabase(TContext) InitializeDatabase(TContext) InitializeDatabase(TContext)

Executes the strategy to initialize the database for the given context.

Seed(TContext) Seed(TContext) Seed(TContext)

A method that should be overridden to actually add data to the context for seeding. The default implementation does nothing.

Applies to