public static ITransformationProvider AddManyToManyJoiningTable(this ITransformationProvider database, string schema, string lhsTableName, string lhsKey, string rhsTableName, string rhsKey, string joiningTableName) { string joiningTableWithSchema = TransformationProviderUtility.FormatTableName(schema, joiningTableName); string joinLhsKey = Inflector.Singularize(lhsTableName) + "Id"; string joinRhsKey = Inflector.Singularize(rhsTableName) + "Id"; database.AddTable(joiningTableWithSchema, new Column(joinLhsKey, DbType.Guid, ColumnProperty.NotNull), new Column(joinRhsKey, DbType.Guid, ColumnProperty.NotNull)); string pkName = "PK_" + joiningTableName; pkName = ShortenKeyNameToBeSuitableForOracle(pkName); database.AddPrimaryKey(pkName, joiningTableWithSchema, joinLhsKey, joinRhsKey); string lhsTableNameWithSchema = TransformationProviderUtility.FormatTableName(schema, lhsTableName); string rhsTableNameWithSchema = TransformationProviderUtility.FormatTableName(schema, rhsTableName); string lhsFkName = TransformationProviderUtility.CreateForeignKeyName(lhsTableName, joiningTableName); database.AddForeignKey(lhsFkName, joiningTableWithSchema, joinLhsKey, lhsTableNameWithSchema, lhsKey, ForeignKeyConstraintType.NoAction); string rhsFkName = TransformationProviderUtility.CreateForeignKeyName(rhsTableName, joiningTableName); database.AddForeignKey(rhsFkName, joiningTableWithSchema, joinRhsKey, rhsTableNameWithSchema, rhsKey, ForeignKeyConstraintType.NoAction); return(database); }
public static ITransformationProvider RemoveManyToManyJoiningTable(this ITransformationProvider database, string schema, string lhsTableName, string rhsTableName, string joiningTableName) { string joiningTableNameWithSchema = TransformationProviderUtility.FormatTableName(schema, joiningTableName); string lhsFkName = TransformationProviderUtility.CreateForeignKeyName(lhsTableName, joiningTableName); string rhsFkName = TransformationProviderUtility.CreateForeignKeyName(rhsTableName, joiningTableName); database.RemoveForeignKey(joiningTableNameWithSchema, lhsFkName); database.RemoveForeignKey(joiningTableNameWithSchema, rhsFkName); database.RemoveTable(joiningTableNameWithSchema); return(database); }