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)

SystemObject
  System.Data.EntityCreateDatabaseIfNotExists

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> = 
    class
        interface IDatabaseInitializer<'TContext>
    end
Public Class CreateDatabaseIfNotExists(Of TContext As DbContext)
	Implements IDatabaseInitializer(Of TContext)

Type Parameters

TContext

The type of the context.

NameDescription
System_CAPS_pubmethod CreateDatabaseIfNotExists

Initializes a new instance of the CreateDatabaseIfNotExists class.

NameDescription
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