private void GenerateIndependentAssociationType( EdmAssociationType associationType, DbDatabaseMapping databaseMapping) { //Contract.Requires(associationType != null); //Contract.Requires(databaseMapping != null); EdmAssociationEnd principalEnd, dependentEnd; if (!associationType.TryGuessPrincipalAndDependentEnds(out principalEnd, out dependentEnd)) { if (!associationType.IsPrincipalConfigured()) { throw Error.UnableToDeterminePrincipal( associationType.SourceEnd.EntityType.GetClrType(), associationType.TargetEnd.EntityType.GetClrType()); } principalEnd = associationType.SourceEnd; dependentEnd = associationType.TargetEnd; } var dependentEntityTypeMapping = GetEntityTypeMappingInHierarchy(databaseMapping, dependentEnd.EntityType); var dependentTable = dependentEntityTypeMapping .TypeMappingFragments .First() .Table; var associationSetMapping = GenerateAssociationSetMapping( associationType, databaseMapping, principalEnd, dependentEnd, dependentTable); GenerateIndependentForeignKeyConstraint( databaseMapping, principalEnd.EntityType, dependentEnd.EntityType, dependentTable, associationSetMapping, associationSetMapping.SourceEndMapping, associationType.Name, principalEnd); foreach (var property in dependentEnd.EntityType.KeyProperties()) { associationSetMapping.TargetEndMapping.PropertyMappings.Add( new DbEdmPropertyMapping { Column = dependentEntityTypeMapping.GetPropertyMapping(property).Column, PropertyPath = new[] { property } }); } }