[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())); }
[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())); } }
[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())); } }