src/EntityFramework/DropCreateDatabaseIfModelChanges`.cs
/// <summary>
/// Executes the strategy to initialize the database for the given context.
/// </summary>
/// <param name="context"> The context. </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="context" />
/// is
/// <c>null</c>
/// .
/// </exception>
Executes the strategy to initialize the database for the given context.
Executes the strategy to initialize the database for the given context .
public virtual void InitializeDatabase(TContext context)
        {
            Check.NotNull(context, "context");
            var existence = new DatabaseTableChecker().AnyModelTableExists(context.InternalContext);
            if (existence == DatabaseExistenceState.Exists)
            {
                if (context.Database.CompatibleWithModel(throwIfNoMetadata: true))
                {
                    return;
                }
                context.Database.Delete();
                existence = DatabaseExistenceState.DoesNotExist;
            }
            context.Database.Create(existence);
            Seed(context);
            context.SaveChanges();
        }
public virtual void InitializeDatabase ( TContext context ) { Check . NotNull ( context , " " ) ; var existence = new DatabaseTableChecker ( ) . AnyModelTableExists ( context . InternalContext ) ; if ( existence == DatabaseExistenceState . Exists ) { if ( context . Database . CompatibleWithModel ( throwIfNoMetadata : true ) ) { return ; } context . Database . Delete ( ) ; existence = DatabaseExistenceState . DoesNotExist ; } context . Database . Create ( existence ) ; Seed ( context ) ; context . SaveChanges ( ) ; }
Executes the strategy to initialize the database for the given context.
Executes the strategy to initialize the database for the given context .
// Database didn't exist or we deleted it, so we now create it again.
None
context
TContext
None