Beispiel #1
0
 public void Initialize()
 {
     using (BombasContext context = new BombasContext())
     {
         int currentVersion = 0;
         if (context.SchemaInfoes.Count() > 0)
         {
             currentVersion = context.SchemaInfoes.Max(x => x.Version);
         }
         BombasContextHelper mmSqliteHelper = new BombasContextHelper();
         while (currentVersion < RequiredDatabaseVersion)
         {
             currentVersion++;
             foreach (string migration in mmSqliteHelper.Migrations[currentVersion])
             {
                 context.Database.ExecuteSqlCommand(migration);
             }
             context.SchemaInfoes.Add(new SchemaInfo()
             {
                 Version = currentVersion
             });
             context.SaveChanges();
         }
     }
 }
 public void Initialize()
 {
     using (BombasContext context = new BombasContext())
     {
         int currentVersion = 0;
         if (context.SchemaInfoes.Count() > 0)
             currentVersion = context.SchemaInfoes.Max(x => x.Version);
         BombasContextHelper mmSqliteHelper = new BombasContextHelper();
         while (currentVersion < RequiredDatabaseVersion)
         {
             currentVersion++;
             foreach (string migration in mmSqliteHelper.Migrations[currentVersion])
             {
                 context.Database.ExecuteSqlCommand(migration);
             }
             context.SchemaInfoes.Add(new SchemaInfo() { Version = currentVersion });
             context.SaveChanges();
         }
     }
 }