2

Add MVC Controller with views, Using Entity Framework

What I did?

First I created a Asp.net web application project (3.1) with Authentication "Individual User Account"

Project will already have ApplicationDbContext that inherit IdentityDbContext

Scaffolding Identity Pages is not the problem, It run smooth.

Problem is

Create one basic model, In my case ClientArea Now try to scaffold that model, Data Context DropDown is empty, "ApplicationDbContext" is not shown in dropdown, It will prompt to create new DbContext. "How can I use the same ApplicationDbContext on whole project instead of creating another one.

If you any way create new DbContext and again inherit it from IdentityDbContext instead of "DbContext" , now that newly crated context will also not show.

I later tried to create .net core 2.1 mvc from visual studio 2017, and I found scaffolding is working fine there.

So I created new .net core 2.1 mvc from visual studio 2019, but found it has same issue.

So I guess the issue is on the visual studio 2019 instead of .net core itself.

Can somebody confirm please. My current version of visual studio 2019 is Version 16.6.0

1 Answers1

8

I just ran into this problem as well. It must be a bug. At first I thought it was because I have my DbContext class in another assembly but this is not the case.

In order to get around the issue I just changed my DbContext from

public class ApplicationDbContext : IdentityDbContext<IdentityUser>

to

public class ApplicationDbContext : DbContext

then added my scaffolding and changed it back. It's a pain but at least you can continue working and create the pages.

I'm using the same version of VS as well. I just checked Visual Studio Community 2019 Preview Version 16.7.0 Preview 1.0

The problem exists there as well. Looks like you will have to work around the issue and file a bug report.

Manny
  • 426
  • 4
  • 11