public void Setup() { //Create an in-memory DbConnection https://entityframework-effort.net/ var dbConnection = Effort.DbConnectionFactory.CreateTransient(); this._context = new SandwichContext(dbConnection); }
public void Setup() { //https://garywoodfine.com/entity-framework-core-memory-testing-database/ var connection = new SqliteConnection("DataSource=:memory:"); var dbOptions = new DbContextOptionsBuilder <SandwichContext>() .UseSqlite(connection) .Options; _context = new SandwichContext(dbOptions); _context.Database.OpenConnection(); _context.Database.EnsureCreated(); }