public void Saves_Successfully() { using ( var dbContextScope = _dbContextScopeFactory.CreateAmbientDbContextInTransactionMode <BloggerDbContext>()) { //Get the current DbContext of type BloggerDbContext var context = DbContextLocator.GetDbContext <BloggerDbContext>(); //Adding Blog to the database. var blog = new Blog { CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, BlogUser = new User { Name = "TestUser", Occupation = "Software Developer", }, Overview = "This is a test overview" }; context.Blogs.Add(blog); var post = new Post { Content = "Test Content", Meta = "Test", ShortDescription = "This is an example test content", Title = "Ambient Simple Test Context" }; blog.BlogPost = post; dbContextScope.SaveAndCommitChanges(); Assert.That(context.Blogs.Count() == 1); Assert.That(context.Posts.Count() == 1); } }