CreateDatabaseIfNotExists Class

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.

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


public class CreateDatabaseIfNotExists<TContext> : IDatabaseInitializer<TContext>
where TContext : DbContext
generic<typename TContext>
where TContext : DbContext
public ref class CreateDatabaseIfNotExists : IDatabaseInitializer<TContext>
type CreateDatabaseIfNotExists<'TContext when 'TContext : DbContext> = 
        interface IDatabaseInitializer<'TContext>
Public Class CreateDatabaseIfNotExists(Of TContext As DbContext)
	Implements IDatabaseInitializer(Of TContext)

Type Parameters


The type of the context.

System_CAPS_pubmethod CreateDatabaseIfNotExists

Initializes a new instance of the CreateDatabaseIfNotExists class.

System_CAPS_pubmethod Equals

(Inherited from Object.)

System_CAPS_protmethod Finalize

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode

(Inherited from Object.)

System_CAPS_pubmethod GetType

(Inherited from Object.)

System_CAPS_pubmethod InitializeDatabase

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

System_CAPS_protmethod MemberwiseClone

(Inherited from Object.)

System_CAPS_protmethod Seed

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

System_CAPS_pubmethod ToString

(Inherited from Object.)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top