public void Discover_returns_configuration_when_conventional_from_other_end()
        {
            var modelBuilder = new DbModelBuilder();
            modelBuilder.Entity<Entity1>().HasMany(e => e.Entity2s).WithMany(e => e.Entity1s);
            var model = modelBuilder.Build(new DbProviderInfo("System.Data.SqlClient", "2012"));
            var entityType = model.ConceptualModel.EntityTypes.First(t => t.Name == "Entity2");
            var navigationProperty = entityType.NavigationProperties.First(p => p.Name == "Entity1s");

            // NOTE: This makes the model readonly. Without it, assertions fail
            model.Compile();

            var configuration = new JoinTableDiscoverer().Discover(navigationProperty, model) as JoinTableConfiguration;

            Assert.NotNull(configuration);
            Assert.Null(configuration.Schema);
            Assert.Equal("Entity1Entity2", configuration.Table);
            Assert.Empty(configuration.LeftKeys);
            Assert.Empty(configuration.RightKeys);
        }
Example #2
0
        public void Discover_returns_configuration_when_conventional_from_other_end()
        {
            var modelBuilder = new DbModelBuilder();

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

            // NOTE: This makes the model readonly. Without it, assertions fail
            model.Compile();

            var configuration = new JoinTableDiscoverer().Discover(navigationProperty, model) as JoinTableConfiguration;

            Assert.NotNull(configuration);
            Assert.Null(configuration.Schema);
            Assert.Equal("Entity1Entity2", configuration.Table);
            Assert.Empty(configuration.LeftKeys);
            Assert.Empty(configuration.RightKeys);
        }