, . , , , , , - , .
, SQLite , , UseInMemory():
https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/sqlite
: Microsoft.EntityFrameworkCore.Sqlite, Microsoft.Data.Sqlite, .
, , webapi, , , .. .
:
services.AddDbContext<MyDbContext>(options =>
{
var liteConn = new SqliteConnection("DataSource=:memory:");
liteConn.Open();
options
.UseSqlite(liteConn)
.ConfigureWarnings(warnings =>
{
warnings.Throw(RelationalEventId.QueryClientEvaluationWarning);
warnings.Log(RelationalEventId.ExecutedCommand);
});
});
Configure:
if (env.IsDevelopment())
{
var context = app.ApplicationServices.GetRequiredService<MyDbContext>();
context.Database.EnsureCreated();
}