private static SqliteConnection CreateDatabaseAndGetConnection() { var connection = new SqliteConnection("Data Source=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <BookStoreMigrationsDbContext>() .UseSqlite(connection) .Options; using (var context = new BookStoreMigrationsDbContext(options)) { context.GetService <IRelationalDatabaseCreator>().CreateTables(); } return(connection); }
private static SqlConnection CreateDatabaseAndGetConnection() { var connection = new SqlConnection( "Server=(localdb)\\projects;Database=BookStore;Integrated Security=true;MultipleActiveResultSets=true"); connection.Open(); var options = new DbContextOptionsBuilder <BookStoreMigrationsDbContext>() .UseSqlServer(connection) .Options; using (var context = new BookStoreMigrationsDbContext(options)) { context.GetService <IRelationalDatabaseCreator>().CreateTables(); } return(connection); }