Export (0) Print
Expand All

DropCreateDatabaseIfModelChanges<TContext> Class

Entity Framework 5.0

An implementation of IDatabaseInitializer<TContext>that will delete, recreate, and optionally re-seed the database with data only if the model has changed since the database was created. This is achieved by writing a hash of the store model to the database when it is created and then comparing that hash with one generated from the current model. To seed the database, create a derived class and override the Seed method.

System.Object
  System.Data.Entity.DropCreateDatabaseIfModelChanges<TContext>

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

public class DropCreateDatabaseIfModelChanges<TContext> : IDatabaseInitializer<TContext>
where TContext : DbContext

Type Parameters

TContext

The type of the context.

The DropCreateDatabaseIfModelChanges<TContext> type exposes the following members.

  NameDescription
Public methodDropCreateDatabaseIfModelChanges<TContext>Initializes a new instance of the DropCreateDatabaseIfModelChanges<TContext> class.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodInitializeDatabaseExecutes the strategy to initialize the database for the given context.
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodSeedA that should be overridden to actually add data to the context for seeding. The default implementation does nothing.
Public methodToString (Inherited from Object.)
Top

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