Reputation: 883
Error:
DBContext type 'MvcMovieContext' is found but it does not inherit from Microsoft.ASPNetCore.Identity.EntityFrameworkCore.IdentityDBContext
The process I have followed using latest upgrade of Visual Studio 2019: latest relevant & other packages installed (showing Nuget Solution)
StartUp.cs
using Microsoft.EntityFrameworkCore;
using MvcMovie.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddDbContext<MvcMovieContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MvcMovieContext")));
}
After specifying Identity scaffolding template
keep ~Views\Shared_Layout.cshtml page
database context class specified as MvcMovie.Data.MvcMovieContext
no files overwritten
no user class specified
ok
process updates dependencies
builds solution until error
I have reviewed similar issues here and github. The closest I (newbie) could find was UseSqlServer()
method is missing from Microsoft.EntityFrameworkCore.SqlServer
I have looked through the build files of the working MvcMovie
solution. I have updated dependencies. If someone could tell me how to troubleshoot why a DBContext
type "does not inherit from Microsoft.ASPNetCore.Identity.EntityFrameworkCore.IdentityDBContext" then I would be much obliged.
Upvotes: 1
Views: 1461
Reputation: 361
I had the same issue as normally I believe it is good practice to use a different DB context for your authentication , but I'm trying to do my business application all from an Azure free account and you only get 1 database so I need to also use my main DB for authentication. So inheriting from IdentityDbContext instead was what I had to do.
I looked into using Azure Active Directory for my authentication and conditional access but it looked way too involved for a small company of only 5 users. Actually, authentication was quite easy, but creating and implementing conditional access policies was what looked too involved for my simple needs.
Upvotes: 1
Reputation: 53
As @Matt U stated in the comments, changing DbContext
to IdentityDbContext
did the trick, along with including
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
within the context.cs
file.
Upvotes: 1