public virtual void Delete(DbConnection connection) { using (var context = new EmptyContext(connection)) { context.Database.CommandTimeout = _commandTimeout; ((IObjectContextAdapter)context).ObjectContext.DeleteDatabase(); } }
public virtual bool Exists(DbConnection connection) { using (var context = new EmptyContext(connection)) { context.Database.CommandTimeout = _commandTimeout; return ((IObjectContextAdapter)context).ObjectContext.DatabaseExists(); } }
public virtual void Create(DbConnection connection) { using (var context = new EmptyContext(connection)) { // Drop down to ObjectContext here to avoid recursive calls into the Migrations // pipeline and so that MigrationHistory table is not created by DbContext. ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } }
public void Getting_model_does_not_create_database() { using (var connection = ProviderFactory.CreateConnection()) { connection.ConnectionString = ConnectionString; DropDatabase(); using (var emptyContext = new EmptyContext(connection)) { emptyContext.GetModel(); Assert.False(Database.Exists(connection)); } } }
public void Can_get_empty_model() { using (var connection = ProviderFactory.CreateConnection()) { connection.ConnectionString = ConnectionString; using (var emptyContext = new EmptyContext(connection)) { var model = emptyContext.GetModel(); var csdlSchemaNode = model.Descendants(_csdlNamespace + "Schema").Single(); var entityContainer = csdlSchemaNode.Descendants(_csdlNamespace + "EntityContainer").Single(); Assert.Equal(0, entityContainer.Descendants().Count()); } } }