If the specified inverse navigation property wasn't a navigation property to begin with Fluent API doesn't configure it as such.
[Fact]
public void NavigationProperty_doesnt_override_inverse_property()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Entity>()
.HasRequired(e => e.InternalNavigationProperty)
.WithMany(e => e.InternalCollectionNavigationProperty);
var databaseMapping = BuildMapping(modelBuilder);
Assert.Equal(
"InternalCollectionNavigationProperty",
databaseMapping.Model.EntityTypes.Single(t => t.Name == "RelatedEntity")
.NavigationProperties.Single().Name);
}
public class Entity
{
public int Id { get; set; }
internal RelatedEntity InternalNavigationProperty { get; set; }
}
public class RelatedEntity
{
public int Id { get; set; }
internal ICollection<Entity> InternalCollectionNavigationProperty { get; set; }
}
[Fact]
public void NavigationProperty_doesnt_override_inverse_property()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Entity>()
.HasRequired(e => e.InternalNavigationProperty)
.WithMany(e => e.InternalCollectionNavigationProperty);
var databaseMapping = BuildMapping(modelBuilder);
Assert.Equal(
"InternalCollectionNavigationProperty",
databaseMapping.Model.EntityTypes.Single(t => t.Name == "RelatedEntity")
.NavigationProperties.Single().Name);
}
public class Entity
{
public int Id { get; set; }
internal RelatedEntity InternalNavigationProperty { get; set; }
}
public class RelatedEntity
{
public int Id { get; set; }
internal ICollection<Entity> InternalCollectionNavigationProperty { get; set; }
}