Exemplo n.º 1
0
        private static void ConfigureDependentKeys(
            DbDatabaseMapping databaseMapping,
            DbProviderManifest providerManifest)
        {
            IList <EntityType> entityTypeList = databaseMapping.Database.EntityTypes as IList <EntityType> ?? (IList <EntityType>)databaseMapping.Database.EntityTypes.ToList <EntityType>();

            for (int index1 = 0; index1 < entityTypeList.Count; ++index1)
            {
                EntityType entityType = entityTypeList[index1];
                IList <ForeignKeyBuilder> foreignKeyBuilderList = entityType.ForeignKeyBuilders as IList <ForeignKeyBuilder> ?? (IList <ForeignKeyBuilder>)entityType.ForeignKeyBuilders.ToList <ForeignKeyBuilder>();
                for (int index2 = 0; index2 < foreignKeyBuilderList.Count; ++index2)
                {
                    ForeignKeyBuilder         foreignKeyBuilder = foreignKeyBuilderList[index2];
                    IEnumerable <EdmProperty> dependentColumns  = foreignKeyBuilder.DependentColumns;
                    IList <EdmProperty>       edmPropertyList   = dependentColumns as IList <EdmProperty> ?? (IList <EdmProperty>)dependentColumns.ToList <EdmProperty>();
                    for (int index3 = 0; index3 < edmPropertyList.Count; ++index3)
                    {
                        EdmProperty edmProperty = edmPropertyList[index3];
                        System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration configuration = edmProperty.GetConfiguration() as System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration;
                        if (configuration == null || configuration.ColumnType == null)
                        {
                            EdmProperty other = foreignKeyBuilder.PrincipalTable.KeyProperties.ElementAt <EdmProperty>(index3);
                            edmProperty.PrimitiveType = providerManifest.GetStoreTypeFromName(other.TypeName);
                            edmProperty.CopyFrom(other);
                        }
                    }
                }
            }
        }