Skip to content

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. #5705

@dewebeloper

Description

@dewebeloper

After replacing EF Core rc 1 with EF Core rc 2 final I get follor error:

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 object in its constructor and passes it to the base constructor for DbContext.

I have UoW pattern and on initialization on constructor I get DbContext object like on image.
rc2dbcontextissue

In Startup.cs I have next code:

services.AddDbContext<RegistratorDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity<AppUser, IdentityRole>(config =>
            {
                config.User.RequireUniqueEmail = true;
                config.Password.RequiredLength = 6;
                config.Password.RequireUppercase = true;
                config.Password.RequireNonAlphanumeric = false;
            })
            .AddEntityFrameworkStores<RegistratorDbContext>();

What I did wrong and how to fix this issue? I need to mention that same pattern works in RC1.
Thanks in advance.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions