public static void MoveAllForeignKeyConstraintsForColumn( EntityType fromTable, EntityType toTable, EdmProperty column) { ((IEnumerable <ForeignKeyBuilder>)ForeignKeyPrimitiveOperations.FindAllForeignKeyConstraintsForColumn(fromTable, toTable, column).ToArray <ForeignKeyBuilder>()).Each <ForeignKeyBuilder>((Action <ForeignKeyBuilder>)(fk => ForeignKeyPrimitiveOperations.MoveForeignKeyConstraint(fromTable, toTable, fk))); }
public static void CopyAllForeignKeyConstraintsForColumn( EdmModel database, EntityType fromTable, EntityType toTable, EdmProperty column, EdmProperty movedColumn) { ((IEnumerable <ForeignKeyBuilder>)ForeignKeyPrimitiveOperations.FindAllForeignKeyConstraintsForColumn(fromTable, toTable, column).ToArray <ForeignKeyBuilder>()).Each <ForeignKeyBuilder>((Action <ForeignKeyBuilder>)(fk => ForeignKeyPrimitiveOperations.CopyForeignKeyConstraint(database, toTable, fk, (Func <EdmProperty, EdmProperty>)(c => { if (c != column) { return(c); } return(movedColumn); })))); }
public static void CopyAllForeignKeyConstraintsForPrimaryKeyColumns( EdmModel database, EntityType fromTable, EntityType toTable) { foreach (EdmProperty keyProperty in fromTable.KeyProperties) { ((IEnumerable <ForeignKeyBuilder>)ForeignKeyPrimitiveOperations.FindAllForeignKeyConstraintsForColumn(fromTable, toTable, keyProperty).ToArray <ForeignKeyBuilder>()).Each <ForeignKeyBuilder>((Action <ForeignKeyBuilder>)(fk => { if (fk.GetIsTypeConstraint()) { return; } ForeignKeyPrimitiveOperations.CopyForeignKeyConstraint(database, toTable, fk, (Func <EdmProperty, EdmProperty>)null); })); } }
public static void MoveAllDeclaredForeignKeyConstraintsForPrimaryKeyColumns( EntityType entityType, EntityType fromTable, EntityType toTable) { foreach (EdmProperty keyProperty in fromTable.KeyProperties) { ((IEnumerable <ForeignKeyBuilder>)ForeignKeyPrimitiveOperations.FindAllForeignKeyConstraintsForColumn(fromTable, toTable, keyProperty).ToArray <ForeignKeyBuilder>()).Each <ForeignKeyBuilder>((Action <ForeignKeyBuilder>)(fk => { AssociationType associationType = fk.GetAssociationType(); if (associationType == null || associationType.Constraint.ToRole.GetEntityType() != entityType || fk.GetIsTypeConstraint()) { return; } ForeignKeyPrimitiveOperations.MoveForeignKeyConstraint(fromTable, toTable, fk); })); } }