private async Task <IEnumerable <OperationsMigration> > LoadMirationsAsync(IDataMigration instance, int version) { var type = instance.GetType(); var migration = instance as DataMigration; if (migration != null) { InitDataMigration(migration); } var dbMigration = await _reposority.FindMigrationAsync(type.FullName); if ((dbMigration == null && version == -1) || //卸载 (dbMigration != null && dbMigration.Version == version)) //版本已经是设置的版本 { return(null); } if (version == 0) //安装版本设为最大值 { version = int.MaxValue; } if (dbMigration == null || version > dbMigration.Version) { return(Upgrade(migration, dbMigration, version)); } if (dbMigration.Version > version) { return(Downgrade(migration, dbMigration, version)); } return(null); }