Esempio n. 1
0
 public virtual IEnumerable<MigrationInfo> GetMigrations(String contextTypeName)
 {
     var contextType = GetContextType(contextTypeName);
     var configurationType = GetConfigurationType(contextType);
     
     var configuration = CreateConfiguration(configurationType);
     var migrator = new DbMigrator(configuration);
     
     var migrations = new Dictionary<String, MigrationInfo>();
     
     Func<String, MigrationInfo> getInfo = migrationId =>
     {
         MigrationInfo info;
         
         if (!migrations.TryGetValue(migrationId, out info))
         {
             info = new MigrationInfo { Id = migrationId };
             migrations.Add(migrationId, info);
         }
         
         return info;
     };
     
     foreach (var migrationId in migrator.GetDatabaseMigrations())
     {
         var info = getInfo.Invoke(migrationId);
         
         info.InDatabase = true;
     }
     
     foreach (var migrationId in migrator.GetLocalMigrations())
     {
         var info = getInfo.Invoke(migrationId);
         
         info.InProject = true;
     }
     
     return migrations.Values.OrderBy(i => i.Id);
 }