Example #1
0
        internal void Configure(
            EntityType entityType,
            DbDatabaseMapping databaseMapping,
            DbProviderManifest providerManifest)
        {
            EntityTypeMapping entityTypeMapping = databaseMapping.GetEntityTypeMapping(EntityTypeExtensions.GetClrType(entityType));

            if (entityTypeMapping != null)
            {
                EntityTypeConfiguration.VerifyAllCSpacePropertiesAreMapped((ICollection <EntityTypeMapping>)databaseMapping.GetEntityTypeMappings(entityType).ToList <EntityTypeMapping>(), (IEnumerable <EdmProperty>)entityTypeMapping.EntityType.DeclaredProperties, (IList <EdmProperty>) new List <EdmProperty>());
            }
            this.ConfigurePropertyMappings(databaseMapping, entityType, providerManifest, false);
            this.ConfigureAssociationMappings(databaseMapping, entityType, providerManifest);
            EntityTypeConfiguration.ConfigureDependentKeys(databaseMapping, providerManifest);
            this.ConfigureModificationStoredProcedures(databaseMapping, entityType, providerManifest);
        }
Example #2
0
        private static void VerifyAllCSpacePropertiesAreMapped(
            ICollection <EntityTypeMapping> entityTypeMappings,
            IEnumerable <EdmProperty> properties,
            IList <EdmProperty> propertyPath)
        {
            EntityType entityType = entityTypeMappings.First <EntityTypeMapping>().EntityType;

            foreach (EdmProperty property in properties)
            {
                propertyPath.Add(property);
                if (property.IsComplexType)
                {
                    EntityTypeConfiguration.VerifyAllCSpacePropertiesAreMapped(entityTypeMappings, (IEnumerable <EdmProperty>)property.ComplexType.Properties, propertyPath);
                }
                else if (!entityTypeMappings.SelectMany <EntityTypeMapping, MappingFragment>((Func <EntityTypeMapping, IEnumerable <MappingFragment> >)(etm => (IEnumerable <MappingFragment>)etm.MappingFragments)).SelectMany <MappingFragment, ColumnMappingBuilder>((Func <MappingFragment, IEnumerable <ColumnMappingBuilder> >)(mf => mf.ColumnMappings)).Any <ColumnMappingBuilder>((Func <ColumnMappingBuilder, bool>)(pm => pm.PropertyPath.SequenceEqual <EdmProperty>((IEnumerable <EdmProperty>)propertyPath))) && !entityType.Abstract)
                {
                    throw Error.InvalidEntitySplittingProperties((object)entityType.Name);
                }
                propertyPath.Remove(property);
            }
        }