public void BuildPropertyMapping_does_not_build_property_mappings_for_foreign_key_properties_if_foreign_keys_disabled()
        {
            var storeEntityType =
                EntityType.Create(
                    "foo",
                    "bar",
                    DataSpace.SSpace,
                    new[] { "Id" },
                    new[]
            {
                CreateStoreProperty("Id", "int"),
                CreateStoreProperty("ForeignKey", "int"),
            },
                    null);

            var mappingContext = new SimpleMappingContext(new EdmModel(DataSpace.SSpace), false);

            mappingContext.StoreForeignKeyProperties.Add(storeEntityType.Properties.Single(p => p.Name == "ForeignKey"));

            foreach (var storeProperty in storeEntityType.Properties)
            {
                mappingContext.AddMapping(
                    storeProperty,
                    EdmProperty.CreatePrimitive(
                        storeProperty.Name + "Model",
                        (PrimitiveType)storeProperty.TypeUsage.EdmType));
            }

            var propertyMappings =
                DbDatabaseMappingBuilder
                .BuildPropertyMapping(storeEntityType, mappingContext);

            Assert.Equal(
                new[] { "Id" },
                propertyMappings.Select(m => m.ColumnProperty.Name));

            Assert.Equal(
                new[] { "IdModel" },
                propertyMappings.SelectMany(m => m.PropertyPath, (m, p) => p.Name));
        }
        public void BuildPropertyMapping_creates_valid_property_mappings()
        {
            var storeEntityType =
                EntityType.Create(
                    "foo",
                    "bar",
                    DataSpace.SSpace,
                    new[] { "Id" },
                    new[]
            {
                CreateStoreProperty("Id", "int"),
                CreateStoreProperty("FirstName", "nvarchar"),
                CreateStoreProperty("LastName", "char")
            },
                    null);

            var mappingContext = new SimpleMappingContext(new EdmModel(DataSpace.SSpace), true);

            foreach (var storeProperty in storeEntityType.Properties)
            {
                mappingContext.AddMapping(
                    storeProperty,
                    EdmProperty.CreatePrimitive(
                        storeProperty.Name + "Model",
                        (PrimitiveType)storeProperty.TypeUsage.EdmType));
            }

            var propertyMappings =
                DbDatabaseMappingBuilder
                .BuildPropertyMapping(storeEntityType, mappingContext);

            Assert.Equal(
                new[] { "Id", "FirstName", "LastName" },
                propertyMappings.Select(m => m.ColumnProperty.Name));

            Assert.Equal(
                new[] { "IdModel", "FirstNameModel", "LastNameModel" },
                propertyMappings.SelectMany(m => m.PropertyPath, (m, p) => p.Name));
        }