/// <summary> /// 在 Up/Down 方法中调用此方法来添加迁移操作。 /// </summary> /// <param name="operation"></param> protected void AddOperation(MigrationOperation operation) { this._operations.Add(operation); }
/// <summary> /// 把抽象的操作分发到具体的生成方法上。 /// </summary> /// <param name="op"></param> private void Distribute(MigrationOperation op) { //手工分发的原因:类并不多、可以处理类之间的继承层次关系。 if (op is CreateNormalColumn) { this.Generate(op as CreateNormalColumn); } else if (op is DropNormalColumn) { this.Generate(op as DropNormalColumn); } else if (op is AddPKConstraint) { this.Generate(op as AddPKConstraint); } else if (op is RemovePKConstraint) { this.Generate(op as RemovePKConstraint); } else if (op is AddNotNullConstraint) { this.Generate(op as AddNotNullConstraint); } else if (op is RemoveNotNullConstraint) { this.Generate(op as RemoveNotNullConstraint); } else if (op is AddNotNullConstraintFK) { this.Generate(op as AddNotNullConstraintFK); } else if (op is RemoveNotNullConstraintFK) { this.Generate(op as RemoveNotNullConstraintFK); } else if (op is AlterColumnType) { this.Generate(op as AlterColumnType); } else if (op is AddFKConstraint) { this.Generate(op as AddFKConstraint); } else if (op is RemoveFKConstraint) { this.Generate(op as RemoveFKConstraint); } else if (op is CreateTable) { this.Generate(op as CreateTable); } else if (op is DropTable) { this.Generate(op as DropTable); } else if (op is CreateDatabase) { this.Generate(op as CreateDatabase); } else if (op is DropDatabase) { this.Generate(op as DropDatabase); } else if (op is RunSql) { this.Generate(op as RunSql); } else if (op is RunAction) { this.Generate(op as RunAction); } else { this.Generate(op); } }
private void AddOperation(MigrationOperation operation) { this._operations.Add(operation); }
protected virtual void Generate(MigrationOperation op) { throw new NotSupportedException(); }