CreateDatabaseIfNotExists<TContext> CreateDatabaseIfNotExists<TContext> CreateDatabaseIfNotExists<TContext> Class

Definition

An implementation of IDatabaseInitializer that will recreate and optionally re-seed the database only if the database does not exist. To seed the database, create a derived class and override the Seed method.

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

Type Parameters

TContext

The type of the context.

Inheritance
CreateDatabaseIfNotExists<TContext>CreateDatabaseIfNotExists<TContext>CreateDatabaseIfNotExists<TContext>
Implements

Constructors

CreateDatabaseIfNotExists<TContext>() CreateDatabaseIfNotExists<TContext>() CreateDatabaseIfNotExists<TContext>()

Initializes a new instance of the CreateDatabaseIfNotExists<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