예제 #1
0
        [ConditionalFact] // Issue #2992
        public void Can_customize_ModelBuilder()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .AddSingleton <IModelCustomizer, MyModelCustomizer>()
                                  .BuildServiceProvider();

            using var context = new JustSomeContext(serviceProvider);
            var model = context.Model;

            Assert.Equal("Us!", model["AllYourModelAreBelongTo"]);
            Assert.Equal("Us!", model.GetEntityTypes().Single(e => e.DisplayName() == "Base")["AllYourBaseAreBelongTo"]);
            Assert.Contains("Peak", model.GetEntityTypes().Select(e => e.DisplayName()));
        }
예제 #2
0
        [Fact] // Issue #2992
        public void Can_customize_ModelBuilder()
        {
            var serviceProvider = new ServiceCollection()
                .AddEntityFrameworkInMemoryDatabase()
                .AddSingleton<IModelCustomizer, MyModelCustomizer>()
                .BuildServiceProvider();

            using (var context = new JustSomeContext(serviceProvider))
            {
                var model = context.Model;
                Assert.Equal("Us!", model["AllYourModelAreBelongTo"]);
                Assert.Equal("Us!", model.GetEntityTypes().Single(e => e.DisplayName() == "Base")["AllYourBaseAreBelongTo"]);
                Assert.Contains("Peak", model.GetEntityTypes().Select(e => e.DisplayName()));
            }
        }
예제 #3
0
        [Fact] // Issue #943
        public void Can_replace_ModelSource_without_access_to_internals()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .AddSingleton <InMemoryModelSource, MyModelSource>()
                                  .BuildServiceProvider();

            using (var context = new JustSomeContext(serviceProvider))
            {
                var model = context.Model;

                Assert.Equal("Us!", model["AllYourModelAreBelongTo"]);
                Assert.Equal("Us!", model.GetEntityTypes().Single(e => e.DisplayName() == "Base")["AllYourBaseAreBelongTo"]);
                Assert.Contains("Peak", model.GetEntityTypes().Select(e => e.DisplayName()));
            }
        }