Exemple #1
0
 protected void SaveSchemaToDatabase(DbContext context)
 {
     using (var ctx = new SchemaVersionContext(context.Database.Connection))
     {
         var entity = new SchemaVersionRow();
         //entity.MigrationId = MigrationAssembly.CreateMigrationId(Strings.InitialCreate);
         entity.CreatedOn = DateTime.UtcNow;
         entity.ModelId   = ModelId;
         entity.VersionId = Assembly.GetExecutingAssembly().GetFileVersion();
         ctx.Version.Add(entity);
         ctx.SaveChanges();
     }
 }
Exemple #2
0
 protected void CreateSchemaVersionTables(DbContext context)
 {
     using (var ctx = new SchemaVersionContext(context.Database.Connection.ConnectionString))
     {
         //using (new TransactionScope(TransactionScopeOption.Suppress))
         {
             var objectContext = ((IObjectContextAdapter)ctx).ObjectContext;
             objectContext.Connection.Open();
             context.Database.ExecuteSqlCommand(objectContext.CreateDatabaseScript());
             var entity = new SchemaVersionRow();
             //entity.MigrationId = MigrationAssembly.CreateMigrationId(Strings.InitialCreate);
             entity.CreatedOn = DateTime.UtcNow;
             entity.ModelId   = ModelId;
             entity.VersionId = Assembly.GetExecutingAssembly().GetFileVersion();
             ctx.Version.Add(entity);
             ctx.SaveChanges();
             objectContext.Connection.Close();
         }
     }
 }