I upgraded my .NET 2.0 web application from .NET 3.0. It now compiles but when I try to login I am getting error "InvalidOperationException: Cannot create a DbSet for 'ApplicationUser' because this type is not included in the model for the context". Obviously the call to database cannot be done but I can't see what my error is.
I got this in Startup.cs (ConfigureServices)
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<ApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
Here is my ApplicationDBContext.cs:
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
}
The error stack reads like this:
Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityType() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.CheckState() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityQueryable() Microsoft.EntityFrameworkCore.Internal.InternalDbSet.System.Linq.IQueryable.get_Provider() Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken) Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, LambdaExpression expression, CancellationToken cancellationToken) Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(IQueryable source, Expression> predicate, CancellationToken cancellationToken) Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserOnlyStore.FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken) Microsoft.AspNetCore.Identity.UserManager.FindByNameAsync(string userName) Microsoft.AspNetCore.Identity.SignInManager.PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure) ImSmart.Controllers.AccountController.Login(LoginViewModel model, string returnUrl) in AccountController.cs + var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, lockoutOnFailure: true); Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
What might I be missing?