public void Can_save_and_query_with_explicit_services_and_no_config() { var services = new ServiceCollection(); services.AddEntityFramework().AddInMemoryStore(); var serviceProvider = services.BuildServiceProvider(); using (var context = new ExplicitServicesAndNoConfigBlogContext(serviceProvider)) { context.Blogs.Add(new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } using (var context = new ExplicitServicesAndNoConfigBlogContext(serviceProvider)) { var blog = context.Blogs.SingleOrDefault(); Assert.NotEqual(0, blog.Id); Assert.Equal("The Waffle Cart", blog.Name); context.Blogs.Remove(context.Blogs.ToArray()); context.SaveChanges(); Assert.Empty(context.Blogs); } }
public void Can_save_and_query_with_explicit_services_and_no_config() { var services = new ServiceCollection(); services.AddEntityFramework().AddInMemoryStore(); var serviceProvider = services.BuildServiceProvider(); using (var context = new ExplicitServicesAndNoConfigBlogContext(serviceProvider)) { context.Blogs.Add(new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } using (var context = new ExplicitServicesAndNoConfigBlogContext(serviceProvider)) { var blog = context.Blogs.SingleOrDefault(); Assert.NotEqual(0, blog.Id); Assert.Equal("The Waffle Cart", blog.Name); context.Blogs.RemoveRange(context.Blogs); context.SaveChanges(); Assert.Empty(context.Blogs); } }