public BookShopContextFactory() { var contextOptions = new DbContextOptionsBuilder <BookShopContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableSensitiveDataLogging() .Options; EnsureCreation(contextOptions); ContextInstance = new TestBookShopContext(contextOptions); GenreMapper = new GenreMapper(); ArtistMapper = new AuthorMapper(); BookMapper = new BookMapper(ArtistMapper, GenreMapper); }
private void EnsureCreation(DbContextOptions <BookShopContext> contextOptions) { using var context = new TestBookShopContext(contextOptions); context.Database.EnsureCreated(); }