public void Discover_returns_configuration_when_required_to_optional()
        {
            var modelBuilder = new DbModelBuilder();

            modelBuilder.Entity <Entity1>().HasRequired(e => e.Entity2).WithOptional(e => e.Entity1);
            modelBuilder.Entity <Entity1>().Ignore(e => e.Entity2s);
            modelBuilder.Entity <Entity2>().Ignore(e => e.Entity1s);
            var model              = modelBuilder.Build(new DbProviderInfo("System.Data.SqlClient", "2012"));
            var entityType         = model.ConceptualModel.EntityTypes.First(e => e.Name == "Entity1");
            var navigationProperty = entityType.NavigationProperties.First(p => p.Name == "Entity2");

            bool isDefault;
            var  configuration = MultiplicityDiscoverer.Discover(navigationProperty, out isDefault);

            Assert.False(isDefault);
            Assert.NotNull(configuration);
            Assert.Same(entityType, configuration.LeftEntityType);
            Assert.Same(navigationProperty, configuration.LeftNavigationProperty);
            Assert.Equal(
                RelationshipMultiplicity.ZeroOrOne,
                configuration.LeftNavigationProperty.FromEndMember.RelationshipMultiplicity);
            Assert.Equal(
                RelationshipMultiplicity.One,
                configuration.RightNavigationProperty.FromEndMember.RelationshipMultiplicity);
        }
Example #2
0
 public IFluentConfiguration GetMultiplicityConfiguration(
     NavigationProperty navigationProperty,
     out bool isDefault)
 {
     return(MultiplicityDiscoverer.Discover(navigationProperty, out isDefault));
 }