Support for `UseInMemoryDatabase`?
See original GitHub issueI haven’t set up a reproduction repo yet, but I think my issue is related to inheriting from AuditDbContext
.
I get the following error when I switch my integration tests from SQLite to InMem:
System.InvalidOperationException : No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
My context looks like this:
public partial class MyDbContext : AuditDbContext
{
public MyDbContext (
DbContextOptions<MyDbContext > options)
: base(options)
{
}
I AM using AddDbContext
, as proved by the following:
services.AddDbContext<MyDbContext>(options =>
{
options
//.UseSqlite("Data Source=InMemoryDbForTesting.db") // WORKS!!!
.UseInMemoryDatabase(databaseName: "MyDbContextName") // DOESNT WORK!!!
.UseInternalServiceProvider(dbContextInternalServiceProvider);
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Why can't I call the UseInMemoryDatabase method on ...
According to EF Core: Testing with InMemory reference, you need to add the Microsoft.EntityFrameworkCore.
Read more >InMemoryDbContextOptionsExte...
Configures the context to connect to the legacy shared in-memory database. This method is obsolete. Use UseInMemoryDatabase(DbContextOptionsBuilder, String, ...
Read more >EF Core In-Memory Database Provider
Install; Get Started; Supported Database Engines. This database provider allows Entity Framework Core to be used with an in-memory database.
Read more >How to use EF Core as an in-memory database in ASP. ...
EF Core is a lightweight, open-source, extensible ORM (Object Relational Mapper) that supports several database providers including SQLite, ...
Read more >Fix: DbContextOptionsBuilder Does not contain a definition for ...
... accessible extension method UseInMemoryDatabase accepting a first ... Level Concepts in ADF (Pipeline, Activities, Linked Service etc..).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe my issue was the call to
UseInternalServiceProvider
.It’s possible