public void GetComplexPropertyMappings_should_return_all_complex_property_mappings_for_type() { var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata()); var entitySet = new EdmEntitySet(); var entitySetMapping = databaseMapping.AddEntitySetMapping(entitySet); var entityTypeMapping = new DbEntityTypeMapping(); entitySetMapping.EntityTypeMappings.Add(entityTypeMapping); var entityTypeMappingFragment = new DbEntityTypeMappingFragment(); entityTypeMapping.TypeMappingFragments.Add(entityTypeMappingFragment); var propertyMapping1 = new DbEdmPropertyMapping(); var complexType = new EdmComplexType(); complexType.SetClrType(typeof(object)); propertyMapping1.PropertyPath.Add(new EdmProperty { PropertyType = new EdmTypeReference { EdmType = complexType } }); entityTypeMappingFragment.PropertyMappings.Add(propertyMapping1); var propertyMapping2 = new DbEdmPropertyMapping(); propertyMapping2.PropertyPath.Add(new EdmProperty { PropertyType = new EdmTypeReference() }); propertyMapping2.PropertyPath.Add(new EdmProperty { PropertyType = new EdmTypeReference { EdmType = complexType } }); entityTypeMappingFragment.PropertyMappings.Add(propertyMapping2); Assert.Equal(2, databaseMapping.GetComplexPropertyMappings(typeof(object)).Count()); }
internal void Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) { //Contract.Requires(databaseMapping != null); //Contract.Requires(providerManifest != null); foreach (var structuralTypeConfiguration in databaseMapping.Model.GetComplexTypes() .Select(ct => ct.GetConfiguration()) .Cast<StructuralTypeConfiguration>() .Where(c => c != null)) { structuralTypeConfiguration.Configure( databaseMapping.GetComplexPropertyMappings(structuralTypeConfiguration.ClrType), providerManifest); } ConfigureDefaultSchema(databaseMapping); ConfigureEntityTypes(databaseMapping, providerManifest); RemoveRedundantColumnConditions(databaseMapping); RemoveRedundantTables(databaseMapping); ConfigureTables(databaseMapping.Database); }