public void Configure_should_update_table_name_when_base_type_is_null() { var entityMappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("Foo") }; var entityTypeMapping = new EntityTypeMapping(null); entityTypeMapping.AddType(new EntityType("E", "N", DataSpace.CSpace)); var databaseMapping = new DbDatabaseMapping().Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var table = databaseMapping.Database.AddTable("foo"); var entitySet = databaseMapping.Database.GetEntitySet(table); entityTypeMapping.AddFragment(new MappingFragment(entitySet, entityTypeMapping, false)); entityMappingConfiguration.Configure( databaseMapping, databaseMapping.Model.Container.EntitySets, ProviderRegistry.Sql2008_ProviderManifest, entityTypeMapping.EntityType, ref entityTypeMapping, false, 0, 1, new Dictionary<string, object>()); Assert.Equal("Foo", table.GetTableName().Name); }
private NotNullConditionConfiguration(EntityMappingConfiguration owner, NotNullConditionConfiguration source) { DebugCheck.NotNull(source); DebugCheck.NotNull(owner); _entityMappingConfiguration = owner; PropertyPath = source.PropertyPath; }
private NotNullConditionConfiguration(EntityMappingConfiguration owner, NotNullConditionConfiguration source) { Contract.Requires(source != null); Contract.Requires(owner != null); _entityMappingConfiguration = owner; PropertyPath = source.PropertyPath; }
internal NotNullConditionConfiguration( EntityMappingConfiguration entityMapConfiguration, PropertyPath propertyPath) { Contract.Requires(entityMapConfiguration != null); Contract.Requires(propertyPath != null); _entityMappingConfiguration = entityMapConfiguration; PropertyPath = propertyPath; }
public void TableName_can_get_and_set() { var entityMappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("Foo") }; Assert.Equal("Foo", entityMappingConfiguration.TableName.Name); }
internal NotNullConditionConfiguration( EntityMappingConfiguration entityMapConfiguration, PropertyPath propertyPath) { DebugCheck.NotNull(entityMapConfiguration); DebugCheck.NotNull(propertyPath); _entityMappingConfiguration = entityMapConfiguration; PropertyPath = propertyPath; }
private EntityMappingConfiguration(EntityMappingConfiguration source) { DebugCheck.NotNull(source); _tableName = source._tableName; MapInheritedProperties = source.MapInheritedProperties; if (source._properties != null) { _properties = new List<PropertyPath>(source._properties); } _valueConditions.AddRange(source._valueConditions.Select(c => c.Clone(this))); _notNullConditions.AddRange(source._notNullConditions.Select(c => c.Clone(this))); }
public void AddValueCondition_overwrites_existing_value_for_a_discriminator() { var entityMappingConfiguration1 = new EntityMappingConfiguration(); entityMappingConfiguration1 .AddValueCondition( new ValueConditionConfiguration(entityMappingConfiguration1, "disc") { Value = 1 }); entityMappingConfiguration1 .AddValueCondition( new ValueConditionConfiguration(entityMappingConfiguration1, "disc") { Value = 2 }); Assert.Equal(2, entityMappingConfiguration1.ValueConditions.First().Value); }
public void Configure_entity_splitting_should_throw_if_ignored_property_is_mapped() { EdmModel model = new TestModelBuilder() .Entity("E") .Key("P1"); var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model); var entityType = model.GetEntityType("E"); var modelConfiguration = new ModelConfiguration(); var entityConfiguration = modelConfiguration.Entity(entityType.GetClrType()); var p1PropertyInfo = entityType.GetDeclaredPrimitiveProperty("P1").GetClrPropertyInfo(); var entityMappingConfiguration1 = new EntityMappingConfiguration { Properties = new List<PropertyPath> { new PropertyPath(p1PropertyInfo), new PropertyPath(new MockPropertyInfo(typeof(int), "P2")) }, TableName = new DatabaseName("E") }; entityConfiguration.AddMappingConfiguration(entityMappingConfiguration1); Assert.Equal( Strings.EntityMappingConfiguration_CannotMapIgnoredProperty("E", "P2"), Assert.Throws<InvalidOperationException>( () => modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest)).Message); }
public void AddMappingConfiguration_multiple_mapping_fragments_for_different_tables_allowed() { var entityTypeConfiguration = new EntityTypeConfiguration(new MockType("E1")); var entityMappingConfiguration1 = new EntityMappingConfiguration { TableName = new DatabaseName("E1Table") }; entityTypeConfiguration.AddMappingConfiguration(entityMappingConfiguration1); entityTypeConfiguration.AddMappingConfiguration( new EntityMappingConfiguration { TableName = new DatabaseName("E1TableExtended") }); }
public void Configure_mapping_can_process_two_levels_of_TPH() { //Setup var model = TestModelBuilderHelpers.CreateTwoLevelInheritanceWithThreeEntities(); var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest).Generate(model); var entityType1 = model.GetEntityType("E1"); var entityType2 = model.GetEntityType("E2"); var entityType3 = model.GetEntityType("E3"); // Action var modelConfiguration = new ModelConfiguration(); var entity1Configuration = modelConfiguration.Entity(entityType1.GetClrType()); var entity1MappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1MappingConfiguration, "disc") { Value = 1 }); entity1Configuration.AddMappingConfiguration(entity1MappingConfiguration); var entity1SubTypeMappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1SubTypeMappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1SubTypeMappingConfiguration, "disc") { Value = 3 }); entity1SubTypeMappingConfiguration .AddNullabilityCondition( new NotNullConditionConfiguration( entity1SubTypeMappingConfiguration, new PropertyPath( entityType3.GetDeclaredPrimitiveProperties().SingleOrDefault(p => p.Name == "P4").GetClrPropertyInfo()))); entity1Configuration.AddSubTypeMappingConfiguration(entityType3.GetClrType(), entity1SubTypeMappingConfiguration); var entity2Configuration = modelConfiguration.Entity(entityType2.GetClrType()); var entity2MappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity2MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity2MappingConfiguration, "disc") { Value = 2 }); entity2Configuration.AddMappingConfiguration(entity2MappingConfiguration); modelConfiguration.NormalizeConfigurations(); modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); //Validate var entitySetMapping = databaseMapping.GetEntitySetMapping(model.GetEntitySet(entityType1)); Assert.NotNull(entitySetMapping); Assert.Equal(4, entitySetMapping.EntityTypeMappings.Count()); var entityType1Mapping = databaseMapping.GetEntityTypeMapping(entityType1); var entityType1MappingConditions = databaseMapping.GetEntityTypeMappings(entityType1).Single(x => !x.IsHierarchyMapping); var entityType2Mapping = databaseMapping.GetEntityTypeMapping(entityType2); var entityType3Mapping = databaseMapping.GetEntityTypeMapping(entityType3); var table1 = entityType1Mapping.MappingFragments.Single().Table; var table2 = entityType2Mapping.MappingFragments.Single().Table; var table3 = entityType3Mapping.MappingFragments.Single().Table; Assert.True(entityType1Mapping.IsHierarchyMapping); Assert.Equal(5, table1.Properties.Count); Assert.Equal("P1", table1.Properties[0].Name); Assert.Equal("P2", table1.Properties[1].Name); Assert.Equal("P3", table1.Properties[2].Name); Assert.Equal("P4", table1.Properties[3].Name); Assert.Equal("disc", table1.Properties[4].Name); Assert.Equal(2, entityType1Mapping.MappingFragments.Single().ColumnMappings.Count()); Assert.Equal("P1", entityType1Mapping.MappingFragments.Single().ColumnMappings.ElementAt(0).ColumnProperty.Name); Assert.Equal("P2", entityType1Mapping.MappingFragments.Single().ColumnMappings.ElementAt(1).ColumnProperty.Name); Assert.Same( table1.Properties[4], entityType1MappingConditions.MappingFragments.Single().ColumnConditions.Single().Column); Assert.Equal(1, entityType1MappingConditions.MappingFragments.Single().ColumnConditions.Single().Value); Assert.False(entityType2Mapping.IsHierarchyMapping); Assert.Same(table1, table2); Assert.Same(table1.Properties[0], table2.Properties[0]); Assert.Same(table1.Properties[1], table2.Properties[1]); Assert.Equal(2, entityType2Mapping.MappingFragments.Single().ColumnMappings.Count()); Assert.Equal("P1", entityType2Mapping.MappingFragments.Single().ColumnMappings.ElementAt(0).ColumnProperty.Name); Assert.Equal("P3", entityType2Mapping.MappingFragments.Single().ColumnMappings.ElementAt(1).ColumnProperty.Name); Assert.Same(table2.Properties[4], entityType2Mapping.MappingFragments.Single().ColumnConditions.Single().Column); Assert.Equal(2, entityType2Mapping.MappingFragments.Single().ColumnConditions.Single().Value); Assert.Null(entityType2Mapping.MappingFragments.Single().ColumnConditions.Single().IsNull); Assert.False(entityType3Mapping.IsHierarchyMapping); Assert.Same(table1, table3); Assert.Same(table1.Properties[0], table3.Properties[0]); Assert.Same(table1.Properties[1], table3.Properties[1]); Assert.Equal(3, entityType3Mapping.MappingFragments.Single().ColumnMappings.Count()); Assert.Equal("P1", entityType3Mapping.MappingFragments.Single().ColumnMappings.ElementAt(0).ColumnProperty.Name); Assert.Equal("P3", entityType3Mapping.MappingFragments.Single().ColumnMappings.ElementAt(1).ColumnProperty.Name); Assert.Equal("P4", entityType3Mapping.MappingFragments.Single().ColumnMappings.ElementAt(2).ColumnProperty.Name); Assert.Same(table3.Properties[4], entityType3Mapping.MappingFragments.Single().ColumnConditions.ElementAt(0).Column); Assert.Equal(3, entityType3Mapping.MappingFragments.Single().ColumnConditions.ElementAt(0).Value); Assert.Equal("int", entityType3Mapping.MappingFragments.Single().ColumnConditions.ElementAt(0).Column.TypeName); Assert.Same(table3.Properties[3], entityType3Mapping.MappingFragments.Single().ColumnConditions.ElementAt(1).Column); Assert.Equal(false, entityType3Mapping.MappingFragments.Single().ColumnConditions.ElementAt(1).IsNull); }
public static void Property_mapping_configurations_are_created_and_stored_correctly() { var entityMappingConfiguration = new EntityMappingConfiguration <MyEntity>(); var primitivePropertyConfigurations = entityMappingConfiguration.EntityMappingConfigurationInstance.PrimitivePropertyConfigurations; PropertyMappingConfiguration configuration; Expression <Func <MyEntity, MyStruct> > expression1 = e => e.StructProperty; configuration = entityMappingConfiguration.Property(expression1); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression1.GetComplexPropertyAccess()]); Expression <Func <MyEntity, MyStruct?> > expression2 = e => e.NullableStructProperty; configuration = entityMappingConfiguration.Property(expression2); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression2.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DbGeometry> > expression3 = e => e.DbGeometryProperty; configuration = entityMappingConfiguration.Property(expression3); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression3.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DbGeography> > expression4 = e => e.DbGeographyProperty; configuration = entityMappingConfiguration.Property(expression4); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression4.GetComplexPropertyAccess()]); Expression <Func <MyEntity, string> > expression5 = e => e.StringProperty; configuration = entityMappingConfiguration.Property(expression5); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression5.GetComplexPropertyAccess()]); Expression <Func <MyEntity, byte[]> > expression6 = e => e.ByteArrayProperty; configuration = entityMappingConfiguration.Property(expression6); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression6.GetComplexPropertyAccess()]); Expression <Func <MyEntity, decimal> > expression7 = e => e.DecimalProperty; configuration = entityMappingConfiguration.Property(expression7); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression7.GetComplexPropertyAccess()]); Expression <Func <MyEntity, decimal?> > expression8 = e => e.NullableDecimalProperty; configuration = entityMappingConfiguration.Property(expression8); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression8.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DateTime> > expression9 = e => e.DateTimeProperty; configuration = entityMappingConfiguration.Property(expression9); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression9.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DateTime?> > expression10 = e => e.NullableDateTimeProperty; configuration = entityMappingConfiguration.Property(expression10); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression10.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DateTimeOffset> > expression11 = e => e.DateTimeOffsetProperty; configuration = entityMappingConfiguration.Property(expression11); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression11.GetComplexPropertyAccess()]); Expression <Func <MyEntity, DateTimeOffset?> > expression12 = e => e.NullableDateTimeOffsetProperty; configuration = entityMappingConfiguration.Property(expression12); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression12.GetComplexPropertyAccess()]); Expression <Func <MyEntity, TimeSpan> > expression13 = e => e.TimeSpanProperty; configuration = entityMappingConfiguration.Property(expression13); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression13.GetComplexPropertyAccess()]); Expression <Func <MyEntity, TimeSpan?> > expression14 = e => e.NullableTimeSpanProperty; configuration = entityMappingConfiguration.Property(expression14); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression14.GetComplexPropertyAccess()]); Assert.Equal(14, primitivePropertyConfigurations.Count); }
public void AddMappingConfiguration_multiple_mapping_fragments_with_no_table_name_throws() { var entityTypeConfiguration = new EntityTypeConfiguration(new MockType("E1")); var entityMappingConfiguration1 = new EntityMappingConfiguration(); entityTypeConfiguration.AddMappingConfiguration(entityMappingConfiguration1); Assert.Equal( Strings.InvalidTableMapping_NoTableName("E1"), Assert.Throws<InvalidOperationException>( () => entityTypeConfiguration .AddMappingConfiguration( new EntityMappingConfiguration { TableName = new DatabaseName("E1Table") })).Message); }
internal void AddSubTypeMappingConfiguration(Type subType, EntityMappingConfiguration mappingConfiguration) { DebugCheck.NotNull(subType); DebugCheck.NotNull(mappingConfiguration); EntityMappingConfiguration _; if (_entitySubTypesMappingConfigurations.TryGetValue(subType, out _)) { throw Error.InvalidChainedMappingSyntax(subType.Name); } _entitySubTypesMappingConfigurations.Add(subType, mappingConfiguration); }
internal static void ConfigureUnconfiguredType( DbDatabaseMapping databaseMapping, ICollection<EntitySet> entitySets, DbProviderManifest providerManifest, EntityType entityType, IDictionary<string, object> commonAnnotations) { var c = new EntityMappingConfiguration(); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType.GetClrType()); c.Configure(databaseMapping, entitySets, providerManifest, entityType, ref entityTypeMapping, false, 0, 1, commonAnnotations); }
public static void Property_is_added_only_once_if_does_not_exist() { var entityMappingConfigurationOfMyEntity = new EntityMappingConfiguration<MyEntity>(); var entityMappingConfiguration = entityMappingConfigurationOfMyEntity.EntityMappingConfigurationInstance; Expression<Func<MyEntity, string>> expression1 = e => e.StringProperty; Expression<Func<MyEntity, decimal>> expression2 = e => e.DecimalProperty; Assert.Null(entityMappingConfiguration.Properties); entityMappingConfigurationOfMyEntity.Property(expression1); Assert.NotNull(entityMappingConfiguration.Properties); Assert.Equal(1, entityMappingConfiguration.Properties.Count); Assert.Equal(expression1.GetComplexPropertyAccess(), entityMappingConfiguration.Properties[0]); entityMappingConfigurationOfMyEntity.Property(expression2); Assert.Equal(2, entityMappingConfiguration.Properties.Count); Assert.Equal(expression1.GetComplexPropertyAccess(), entityMappingConfiguration.Properties[0]); Assert.Equal(expression2.GetComplexPropertyAccess(), entityMappingConfiguration.Properties[1]); entityMappingConfigurationOfMyEntity.Property(expression1); Assert.Equal(2, entityMappingConfiguration.Properties.Count); Assert.Equal(expression1.GetComplexPropertyAccess(), entityMappingConfiguration.Properties[0]); Assert.Equal(expression2.GetComplexPropertyAccess(), entityMappingConfiguration.Properties[1]); }
private void Transform() { foreach (EntitySet entitySet1 in this._entityTypes.GetEntitySets()) { EntitySet entitySet = entitySet1; Dictionary <TableMapping, Dictionary <EntityType, EntityTypeMapping> > dictionary = new Dictionary <TableMapping, Dictionary <EntityType, EntityTypeMapping> >(); foreach (EntityType entityType1 in this._entityTypes.GetEntityTypes(entitySet)) { EntityType entityType = entityType1; foreach (TableMapping tableMapping in this._tableMappings.Values.Where <TableMapping>((Func <TableMapping, bool>)(tm => tm.EntityTypes.Contains(entitySet, entityType)))) { Dictionary <EntityType, EntityTypeMapping> rootMappings; if (!dictionary.TryGetValue(tableMapping, out rootMappings)) { rootMappings = new Dictionary <EntityType, EntityTypeMapping>(); dictionary.Add(tableMapping, rootMappings); } EntityMappingService.RemoveRedundantDefaultDiscriminators(tableMapping); bool requiresIsTypeOf = this.DetermineRequiresIsTypeOf(tableMapping, entitySet, entityType); EntityTypeMapping propertiesTypeMapping; MappingFragment propertiesTypeMappingFragment; if (this.FindPropertyEntityTypeMapping(tableMapping, entitySet, entityType, requiresIsTypeOf, out propertiesTypeMapping, out propertiesTypeMappingFragment)) { bool entityTypeMapping1 = EntityMappingService.DetermineRequiresSplitEntityTypeMapping(tableMapping, entityType, requiresIsTypeOf); EntityTypeMapping conditionTypeMapping = this.FindConditionTypeMapping(entityType, entityTypeMapping1, propertiesTypeMapping); MappingFragment typeMappingFragment = EntityMappingService.FindConditionTypeMappingFragment(this._databaseMapping.Database.GetEntitySet(tableMapping.Table), propertiesTypeMappingFragment, conditionTypeMapping); if (requiresIsTypeOf) { if (!propertiesTypeMapping.IsHierarchyMapping) { EntityTypeMapping entityTypeMapping2 = this._databaseMapping.GetEntityTypeMappings(entityType).SingleOrDefault <EntityTypeMapping>((Func <EntityTypeMapping, bool>)(etm => etm.IsHierarchyMapping)); if (entityTypeMapping2 == null) { if (propertiesTypeMapping.MappingFragments.Count > 1) { EntityTypeMapping typeMapping = propertiesTypeMapping.Clone(); this._databaseMapping.GetEntitySetMappings().Single <EntitySetMapping>((Func <EntitySetMapping, bool>)(esm => esm.EntityTypeMappings.Contains(propertiesTypeMapping))).AddTypeMapping(typeMapping); foreach (MappingFragment fragment in propertiesTypeMapping.MappingFragments.Where <MappingFragment>((Func <MappingFragment, bool>)(tmf => tmf != propertiesTypeMappingFragment)).ToArray <MappingFragment>()) { propertiesTypeMapping.RemoveFragment(fragment); typeMapping.AddFragment(fragment); } } propertiesTypeMapping.AddIsOfType(propertiesTypeMapping.EntityType); } else { propertiesTypeMapping.RemoveFragment(propertiesTypeMappingFragment); if (propertiesTypeMapping.MappingFragments.Count == 0) { this._databaseMapping.GetEntitySetMapping(entitySet).RemoveTypeMapping(propertiesTypeMapping); } propertiesTypeMapping = entityTypeMapping2; propertiesTypeMapping.AddFragment(propertiesTypeMappingFragment); } } rootMappings.Add(entityType, propertiesTypeMapping); } EntityMappingService.ConfigureTypeMappings(tableMapping, rootMappings, entityType, propertiesTypeMappingFragment, typeMappingFragment); if (propertiesTypeMappingFragment.IsUnmappedPropertiesFragment() && propertiesTypeMappingFragment.ColumnMappings.All <ColumnMappingBuilder>((Func <ColumnMappingBuilder, bool>)(pm => entityType.GetKeyProperties().Contains(pm.PropertyPath.First <EdmProperty>())))) { this.RemoveFragment(entitySet, propertiesTypeMapping, propertiesTypeMappingFragment); if (entityTypeMapping1 && typeMappingFragment.ColumnMappings.All <ColumnMappingBuilder>((Func <ColumnMappingBuilder, bool>)(pm => entityType.GetKeyProperties().Contains(pm.PropertyPath.First <EdmProperty>())))) { this.RemoveFragment(entitySet, conditionTypeMapping, typeMappingFragment); } } EntityMappingConfiguration.CleanupUnmappedArtifacts(this._databaseMapping, tableMapping.Table); foreach (ForeignKeyBuilder foreignKeyBuilder in tableMapping.Table.ForeignKeyBuilders) { AssociationType associationType = foreignKeyBuilder.GetAssociationType(); if (associationType != null && associationType.IsRequiredToNonRequired()) { AssociationEndMember principalEnd; AssociationEndMember dependentEnd; foreignKeyBuilder.GetAssociationType().TryGuessPrincipalAndDependentEnds(out principalEnd, out dependentEnd); if (dependentEnd.GetEntityType() == entityType) { this.MarkColumnsAsNonNullableIfNoTableSharing(entitySet, tableMapping.Table, entityType, foreignKeyBuilder.DependentColumns); } } } } } } this.ConfigureAssociationSetMappingForeignKeys(entitySet); } }
public void Configure_mapping_can_process_entity_splitting() { EdmModel model = new TestModelBuilder() .Entity("E") .Key("P1") .Property("P2") .Property("P3") .Property("P4") .Property("P5"); var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model); var entityType = model.GetEntityType("E"); var modelConfiguration = new ModelConfiguration(); var entityMappingConfiguration1 = new EntityMappingConfiguration { Properties = new List<PropertyPath> { new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P1").GetClrPropertyInfo()), new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P2").GetClrPropertyInfo()), new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P3").GetClrPropertyInfo()) }, TableName = new DatabaseName("E1") }; var entityMappingConfiguration2 = new EntityMappingConfiguration { Properties = new List<PropertyPath> { new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P1").GetClrPropertyInfo()), new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P4").GetClrPropertyInfo()), new PropertyPath(entityType.GetDeclaredPrimitiveProperty("P5").GetClrPropertyInfo()) }, TableName = new DatabaseName("E2") }; var entityConfiguration = modelConfiguration.Entity(entityType.GetClrType()); entityConfiguration.AddMappingConfiguration(entityMappingConfiguration1); entityConfiguration.AddMappingConfiguration(entityMappingConfiguration2); modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType); var table1 = entityTypeMapping.TypeMappingFragments[0].Table; var table2 = entityTypeMapping.TypeMappingFragments[1].Table; Assert.NotSame(table1, table2); Assert.Equal("E1", table1.GetTableName().Name); Assert.Equal("E2", table2.GetTableName().Name); Assert.Equal(3, table1.Columns.Count); Assert.Equal(3, table2.Columns.Count); Assert.Equal(2, entityTypeMapping.TypeMappingFragments.Count); var entityTypeMappingFragment1 = entityTypeMapping.TypeMappingFragments[0]; var entityTypeMappingFragment2 = entityTypeMapping.TypeMappingFragments[1]; Assert.Equal(3, entityTypeMappingFragment1.PropertyMappings.Count); Assert.Equal("P1", entityTypeMappingFragment1.PropertyMappings[0].Column.Name); Assert.Equal("P2", entityTypeMappingFragment1.PropertyMappings[1].Column.Name); Assert.Equal("P3", entityTypeMappingFragment1.PropertyMappings[2].Column.Name); Assert.Equal(3, entityTypeMappingFragment2.PropertyMappings.Count); Assert.Equal("P1", entityTypeMappingFragment2.PropertyMappings[0].Column.Name); Assert.Equal("P4", entityTypeMappingFragment2.PropertyMappings[1].Column.Name); Assert.Equal("P5", entityTypeMappingFragment2.PropertyMappings[2].Column.Name); }
public void Configure_mapping_can_process_simple_TPH_mapping() { //Setup var model = TestModelBuilderHelpers.CreateSimpleInheritanceTwoEntities(); var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model); var entityType1 = model.GetEntityType("E1"); var entityType2 = model.GetEntityType("E2"); // Action var modelConfiguration = new ModelConfiguration(); var entity1Configuration = modelConfiguration.Entity(entityType1.GetClrType()); var entity1MappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1MappingConfiguration, "disc") { Value = "foo" }); entity1Configuration.AddMappingConfiguration(entity1MappingConfiguration); var entity1SubTypeMappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1SubTypeMappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1SubTypeMappingConfiguration, "disc") { Value = "bar" }); entity1Configuration.AddSubTypeMappingConfiguration(entityType2.GetClrType(), entity1SubTypeMappingConfiguration); modelConfiguration.NormalizeConfigurations(); modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); //Validate var entitySetMapping = databaseMapping.GetEntitySetMapping(model.GetEntitySet(entityType1)); Assert.NotNull(entitySetMapping); Assert.Equal(3, entitySetMapping.EntityTypeMappings.Count); var entityType1Mapping = databaseMapping.GetEntityTypeMapping(entityType1); var entityType1MappingConditions = databaseMapping.GetEntityTypeMappings(entityType1).Single(tm => !tm.IsHierarchyMapping); var entityType2Mapping = databaseMapping.GetEntityTypeMapping(entityType2); var table1 = entityType1Mapping.TypeMappingFragments.Single().Table; var table2 = entityType2Mapping.TypeMappingFragments.Single().Table; Assert.True(entityType1Mapping.IsHierarchyMapping); Assert.Equal(4, table1.Columns.Count); Assert.Equal("P1", table1.Columns[0].Name); Assert.Equal("P2", table1.Columns[1].Name); Assert.Equal("P3", table1.Columns[2].Name); Assert.Equal("disc", table1.Columns[3].Name); Assert.Equal(2, entityType1Mapping.TypeMappingFragments.Single().PropertyMappings.Count); Assert.Equal("P1", entityType1Mapping.TypeMappingFragments.Single().PropertyMappings[0].Column.Name); Assert.Equal("P2", entityType1Mapping.TypeMappingFragments.Single().PropertyMappings[1].Column.Name); Assert.Same(table1.Columns[3], entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions.Single().Column); Assert.Equal("foo", entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions.Single().Value); Assert.Equal("nvarchar", entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions.Single().Column.TypeName); Assert.Equal( DatabaseMappingGenerator.DiscriminatorLength, entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions.Single().Column.Facets.MaxLength); Assert.False(entityType2Mapping.IsHierarchyMapping); Assert.Same(table1, table2); Assert.Equal(2, entityType2Mapping.TypeMappingFragments.Single().PropertyMappings.Count); Assert.Same(table1.Columns[0], table2.Columns[0]); Assert.Same(table1.Columns[1], table2.Columns[1]); Assert.Equal("P1", entityType2Mapping.TypeMappingFragments.Single().PropertyMappings[0].Column.Name); Assert.Equal("P3", entityType2Mapping.TypeMappingFragments.Single().PropertyMappings[1].Column.Name); Assert.Same(table2.Columns[3], entityType2Mapping.TypeMappingFragments.Single().ColumnConditions.Single().Column); Assert.Equal("bar", entityType2Mapping.TypeMappingFragments.Single().ColumnConditions.Single().Value); }
public static void Property_mapping_configuration_is_created_only_once_if_does_not_exist() { var entityMappingConfigurationOfMyEntity = new EntityMappingConfiguration<MyEntity>(); var entityMappingConfiguration = entityMappingConfigurationOfMyEntity.EntityMappingConfigurationInstance; Expression<Func<MyEntity, string>> expression = e => e.StringProperty; Assert.Null(entityMappingConfiguration.Properties); var configuration1 = entityMappingConfigurationOfMyEntity.Property(expression); Assert.Equal(1, entityMappingConfiguration.PrimitivePropertyConfigurations.Count); var configuration2 = entityMappingConfigurationOfMyEntity.Property(expression); Assert.Equal(1, entityMappingConfiguration.PrimitivePropertyConfigurations.Count); Assert.Same(configuration1.Configuration, configuration2.Configuration); }
public void HasAnnotation_checks_arguments() { var configuration = new EntityMappingConfiguration<object>(); Assert.Equal( Strings.ArgumentIsNullOrWhitespace("name"), Assert.Throws<ArgumentException>(() => configuration.HasTableAnnotation(null, null)).Message); Assert.Equal( Strings.ArgumentIsNullOrWhitespace("name"), Assert.Throws<ArgumentException>(() => configuration.HasTableAnnotation(" ", null)).Message); Assert.Equal( Strings.BadAnnotationName("Cheese:Pickle"), Assert.Throws<ArgumentException>(() => configuration.HasTableAnnotation("Cheese:Pickle", null)).Message); }
public static void Property_mapping_configurations_are_created_and_stored_correctly() { var entityMappingConfiguration = new EntityMappingConfiguration<MyEntity>(); var primitivePropertyConfigurations = entityMappingConfiguration.EntityMappingConfigurationInstance.PrimitivePropertyConfigurations; PropertyMappingConfiguration configuration; Expression<Func<MyEntity, MyStruct>> expression1 = e => e.StructProperty; configuration = entityMappingConfiguration.Property(expression1); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression1.GetComplexPropertyAccess()]); Expression<Func<MyEntity, MyStruct?>> expression2 = e => e.NullableStructProperty; configuration = entityMappingConfiguration.Property(expression2); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression2.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DbGeometry>> expression3 = e => e.DbGeometryProperty; configuration = entityMappingConfiguration.Property(expression3); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression3.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DbGeography>> expression4 = e => e.DbGeographyProperty; configuration = entityMappingConfiguration.Property(expression4); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression4.GetComplexPropertyAccess()]); Expression<Func<MyEntity, string>> expression5 = e => e.StringProperty; configuration = entityMappingConfiguration.Property(expression5); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression5.GetComplexPropertyAccess()]); Expression<Func<MyEntity, byte[]>> expression6 = e => e.ByteArrayProperty; configuration = entityMappingConfiguration.Property(expression6); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression6.GetComplexPropertyAccess()]); Expression<Func<MyEntity, decimal>> expression7 = e => e.DecimalProperty; configuration = entityMappingConfiguration.Property(expression7); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression7.GetComplexPropertyAccess()]); Expression<Func<MyEntity, decimal?>> expression8 = e => e.NullableDecimalProperty; configuration = entityMappingConfiguration.Property(expression8); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression8.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DateTime>> expression9 = e => e.DateTimeProperty; configuration = entityMappingConfiguration.Property(expression9); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression9.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DateTime?>> expression10 = e => e.NullableDateTimeProperty; configuration = entityMappingConfiguration.Property(expression10); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression10.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DateTimeOffset>> expression11 = e => e.DateTimeOffsetProperty; configuration = entityMappingConfiguration.Property(expression11); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression11.GetComplexPropertyAccess()]); Expression<Func<MyEntity, DateTimeOffset?>> expression12 = e => e.NullableDateTimeOffsetProperty; configuration = entityMappingConfiguration.Property(expression12); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression12.GetComplexPropertyAccess()]); Expression<Func<MyEntity, TimeSpan>> expression13 = e => e.TimeSpanProperty; configuration = entityMappingConfiguration.Property(expression13); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression13.GetComplexPropertyAccess()]); Expression<Func<MyEntity, TimeSpan?>> expression14 = e => e.NullableTimeSpanProperty; configuration = entityMappingConfiguration.Property(expression14); Assert.Same(configuration.Configuration, primitivePropertyConfigurations[expression14.GetComplexPropertyAccess()]); Assert.Equal(14, primitivePropertyConfigurations.Count); }
public void Configure_mapping_can_process_one_level_TPH_on_both_sides_of_tree() { //Setup var model = TestModelBuilderHelpers.CreateSingleLevelInheritanceWithThreeEntities(); var databaseMapping = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(model); var entityType1 = model.GetEntityType("E1"); var entityType2 = model.GetEntityType("E2"); var entityType3 = model.GetEntityType("E3"); // Action var modelConfiguration = new ModelConfiguration(); var entity1Configuration = modelConfiguration.Entity(entityType1.GetClrType()); var entity1MappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1MappingConfiguration, "P3") { Value = null }); entity1MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1MappingConfiguration, "P4") { Value = null }); entity1Configuration.AddMappingConfiguration(entity1MappingConfiguration); var entity1SubTypeMappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity1SubTypeMappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity1SubTypeMappingConfiguration, "P3") { Value = null }); entity1SubTypeMappingConfiguration .AddNullabilityCondition( new NotNullConditionConfiguration( entity1SubTypeMappingConfiguration, new PropertyPath(entityType3.GetDeclaredPrimitiveProperty("P4").GetClrPropertyInfo()))); entity1Configuration.AddSubTypeMappingConfiguration(entityType3.GetClrType(), entity1SubTypeMappingConfiguration); var entity2Configuration = modelConfiguration.Entity(entityType2.GetClrType()); var entity2MappingConfiguration = new EntityMappingConfiguration { TableName = new DatabaseName("E1") }; entity2MappingConfiguration .AddNullabilityCondition( new NotNullConditionConfiguration( entity2MappingConfiguration, new PropertyPath(entityType2.GetDeclaredPrimitiveProperty("P3").GetClrPropertyInfo()))); entity2MappingConfiguration .AddValueCondition( new ValueConditionConfiguration(entity2MappingConfiguration, "P4") { Value = null }); entity2Configuration.AddMappingConfiguration(entity2MappingConfiguration); modelConfiguration.NormalizeConfigurations(); modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest); //Validate var entitySetMapping = databaseMapping.GetEntitySetMapping(model.GetEntitySet(entityType1)); Assert.NotNull(entitySetMapping); Assert.Equal(4, entitySetMapping.EntityTypeMappings.Count); var entityType1Mapping = databaseMapping.GetEntityTypeMapping(entityType1); var entityType1MappingConditions = databaseMapping.GetEntityTypeMappings(entityType1).Single(x => !x.IsHierarchyMapping); var entityType2Mapping = databaseMapping.GetEntityTypeMapping(entityType2); var entityType3Mapping = databaseMapping.GetEntityTypeMapping(entityType3); var table1 = entityType1Mapping.TypeMappingFragments.Single().Table; var table2 = entityType2Mapping.TypeMappingFragments.Single().Table; var table3 = entityType3Mapping.TypeMappingFragments.Single().Table; Assert.True(entityType1Mapping.IsHierarchyMapping); Assert.Equal(4, table1.Columns.Count); Assert.Equal("P1", table1.Columns[0].Name); Assert.Equal("P2", table1.Columns[1].Name); Assert.Equal("P3", table1.Columns[2].Name); Assert.Equal("P4", table1.Columns[3].Name); Assert.Equal(2, entityType1Mapping.TypeMappingFragments.Single().PropertyMappings.Count); Assert.Equal("P1", entityType1Mapping.TypeMappingFragments.Single().PropertyMappings[0].Column.Name); Assert.Equal("P2", entityType1Mapping.TypeMappingFragments.Single().PropertyMappings[1].Column.Name); Assert.Same(table1.Columns[2], entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions[0].Column); Assert.True((bool)entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions[0].IsNull); Assert.Same(table1.Columns[3], entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions[1].Column); Assert.True((bool)entityType1MappingConditions.TypeMappingFragments.Single().ColumnConditions[1].IsNull); Assert.False(entityType2Mapping.IsHierarchyMapping); Assert.Same(table1, table2); Assert.Same(table1.Columns[0], table2.Columns[0]); Assert.Same(table1.Columns[1], table2.Columns[1]); Assert.Equal(2, entityType2Mapping.TypeMappingFragments.Single().PropertyMappings.Count); Assert.Equal("P1", entityType2Mapping.TypeMappingFragments.Single().PropertyMappings[0].Column.Name); Assert.Equal("P3", entityType2Mapping.TypeMappingFragments.Single().PropertyMappings[1].Column.Name); Assert.Same(table1.Columns[3], entityType2Mapping.TypeMappingFragments.Single().ColumnConditions[0].Column); Assert.True((bool)entityType2Mapping.TypeMappingFragments.Single().ColumnConditions[0].IsNull); Assert.Same(table1.Columns[2], entityType2Mapping.TypeMappingFragments.Single().ColumnConditions[1].Column); Assert.False((bool)entityType2Mapping.TypeMappingFragments.Single().ColumnConditions[1].IsNull); Assert.False(entityType3Mapping.IsHierarchyMapping); Assert.Same(table1, table3); Assert.Same(table1.Columns[0], table3.Columns[0]); Assert.Same(table1.Columns[1], table3.Columns[1]); Assert.Equal(2, entityType3Mapping.TypeMappingFragments.Single().PropertyMappings.Count); Assert.Equal("P1", entityType3Mapping.TypeMappingFragments.Single().PropertyMappings[0].Column.Name); Assert.Equal("P4", entityType3Mapping.TypeMappingFragments.Single().PropertyMappings[1].Column.Name); Assert.Same(table1.Columns[2], entityType3Mapping.TypeMappingFragments.Single().ColumnConditions[0].Column); Assert.True((bool)entityType3Mapping.TypeMappingFragments.Single().ColumnConditions[0].IsNull); Assert.Same(table1.Columns[3], entityType3Mapping.TypeMappingFragments.Single().ColumnConditions[1].Column); Assert.False((bool)entityType3Mapping.TypeMappingFragments.Single().ColumnConditions[1].IsNull); }
internal void AddMappingConfiguration(EntityMappingConfiguration mappingConfiguration, bool cloneable = true) { Contract.Requires(mappingConfiguration != null); if (_entityMappingConfigurations.Contains(mappingConfiguration)) { return; } var tableName = mappingConfiguration.TableName; if (tableName != null) { var existingMappingConfiguration = _entityMappingConfigurations .SingleOrDefault(mf => tableName.Equals(mf.TableName)); if (existingMappingConfiguration != null) { throw Error.InvalidTableMapping(ClrType.Name, tableName); } } _entityMappingConfigurations.Add(mappingConfiguration); if (_entityMappingConfigurations.Count > 1 && _entityMappingConfigurations.Where(mc => mc.TableName == null).Any()) { throw Error.InvalidTableMapping_NoTableName(ClrType.Name); } IsTableNameConfigured |= tableName != null; if (!cloneable) { _nonCloneableMappings.Add(mappingConfiguration); } }
internal void AddSubTypeMappingConfiguration(Type subType, EntityMappingConfiguration mappingConfiguration) { Contract.Requires(subType != null); Contract.Requires(mappingConfiguration != null); EntityMappingConfiguration _; if (_entitySubTypesMappingConfigurations.TryGetValue(subType, out _)) { throw Error.InvalidChainedMappingSyntax(subType.Name); } _entitySubTypesMappingConfigurations.Add(subType, mappingConfiguration); }
internal static void ConfigureUnconfiguredType( DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest, EdmEntityType entityType) { var c = new EntityMappingConfiguration(); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType.GetClrType()); c.Configure(databaseMapping, providerManifest, entityType, ref entityTypeMapping, false, 0, 1); }
internal virtual NotNullConditionConfiguration Clone(EntityMappingConfiguration owner) { return new NotNullConditionConfiguration(owner, this); }
private void Transform() { foreach (var entitySet in _entityTypes.GetEntitySets()) { var setRootMappings = new Dictionary <TableMapping, Dictionary <EntityType, EntityTypeMapping> >(); foreach (var entityType in _entityTypes.GetEntityTypes(entitySet)) { foreach ( var tableMapping in _tableMappings.Values.Where(tm => tm.EntityTypes.Contains(entitySet, entityType))) { Dictionary <EntityType, EntityTypeMapping> rootMappings; if (!setRootMappings.TryGetValue(tableMapping, out rootMappings)) { rootMappings = new Dictionary <EntityType, EntityTypeMapping>(); setRootMappings.Add(tableMapping, rootMappings); } RemoveRedundantDefaultDiscriminators(tableMapping); var requiresIsTypeOf = DetermineRequiresIsTypeOf(tableMapping, entitySet, entityType); var requiresSplit = false; // Find the entity type mapping and fragment for this table / entity type mapping where properties will be mapped EntityTypeMapping propertiesTypeMapping; MappingFragment propertiesTypeMappingFragment; if ( !FindPropertyEntityTypeMapping( tableMapping, entitySet, entityType, requiresIsTypeOf, out propertiesTypeMapping, out propertiesTypeMappingFragment)) { continue; } // Determine if the entity type mapping needs to be split into separate properties and condition type mappings. requiresSplit = DetermineRequiresSplitEntityTypeMapping( tableMapping, entityType, requiresIsTypeOf); // Find the entity type mapping and fragment for this table / entity type mapping where conditions will be mapped var conditionTypeMapping = FindConditionTypeMapping(entityType, requiresSplit, propertiesTypeMapping); var conditionTypeMappingFragment = FindConditionTypeMappingFragment( _databaseMapping.Database.GetEntitySet(tableMapping.Table), propertiesTypeMappingFragment, conditionTypeMapping); // Set the IsTypeOf appropriately if (requiresIsTypeOf) { if (propertiesTypeMapping.IsHierarchyMapping == false) { var isTypeOfEntityTypeMapping = _databaseMapping.GetEntityTypeMappings(entityType).SingleOrDefault( etm => etm.IsHierarchyMapping); if (isTypeOfEntityTypeMapping == null) { if (propertiesTypeMapping.MappingFragments.Count > 1) { // Need to create a new entity type mapping with the non-IsTypeOf contents var nonIsTypeOfEntityTypeMapping = propertiesTypeMapping.Clone(); var parentEntitySetMapping = _databaseMapping.GetEntitySetMappings().Single( esm => esm.EntityTypeMappings.Contains(propertiesTypeMapping)); parentEntitySetMapping.AddTypeMapping(nonIsTypeOfEntityTypeMapping); foreach ( var fragment in propertiesTypeMapping.MappingFragments.Where( tmf => tmf != propertiesTypeMappingFragment).ToArray()) { propertiesTypeMapping.RemoveFragment(fragment); nonIsTypeOfEntityTypeMapping.AddFragment(fragment); } } // else we just use the existing property mapping propertiesTypeMapping.AddIsOfType(propertiesTypeMapping.EntityType); } else { // found an existing IsTypeOf mapping, so re-use that one propertiesTypeMapping.RemoveFragment(propertiesTypeMappingFragment); if (propertiesTypeMapping.MappingFragments.Count == 0) { _databaseMapping .GetEntitySetMapping(entitySet) .RemoveTypeMapping(propertiesTypeMapping); } propertiesTypeMapping = isTypeOfEntityTypeMapping; propertiesTypeMapping.AddFragment(propertiesTypeMappingFragment); } } rootMappings.Add(entityType, propertiesTypeMapping); } ConfigureTypeMappings( tableMapping, rootMappings, entityType, propertiesTypeMappingFragment, conditionTypeMappingFragment); if (propertiesTypeMappingFragment.IsUnmappedPropertiesFragment() && propertiesTypeMappingFragment.ColumnMappings.All( pm => entityType.GetKeyProperties().Contains(pm.PropertyPath.First()))) { RemoveFragment(entitySet, propertiesTypeMapping, propertiesTypeMappingFragment); if (requiresSplit && conditionTypeMappingFragment.ColumnMappings.All( pm => entityType.GetKeyProperties().Contains(pm.PropertyPath.First()))) { RemoveFragment(entitySet, conditionTypeMapping, conditionTypeMappingFragment); } } EntityMappingConfiguration.CleanupUnmappedArtifacts(_databaseMapping, tableMapping.Table); foreach (var fkConstraint in tableMapping.Table.ForeignKeyBuilders) { var associationType = fkConstraint.GetAssociationType(); if (associationType != null && associationType.IsRequiredToNonRequired()) { AssociationEndMember _, dependentEnd; fkConstraint.GetAssociationType().TryGuessPrincipalAndDependentEnds( out _, out dependentEnd); if (dependentEnd.GetEntityType() == entityType) { MarkColumnsAsNonNullableIfNoTableSharing( entitySet, tableMapping.Table, entityType, fkConstraint.DependentColumns); } } } } } ConfigureAssociationSetMappingForeignKeys(entitySet); } }