Josh
Josh

Reputation: 1968

Scaffold View with ViewModel in ASP.NET Core 5

I am trying to scaffold views based on a ViewModel in ASP.NET Core 5 project and have been finding it difficult passing through the following stage

enter image description here

I used to be able to pass this stage by deleting the Data Context field but that seems to have become impossible recently. Any ideas on how to scaffold a razor view with a ViewModel on ASP.Net Core 5?

With the DataContext field, it generates an error as shown

enter image description here

The model doesnt need a key. It is a ViewModel. It does not even need to be in the AppDbContext file and it does not need to be be in the database for any reason

Upvotes: 7

Views: 1392

Answers (1)

EA RZ
EA RZ

Reputation: 21

The datacontext class says it's required but it's actually not.
I had the same problem and you can just leave it like it is

enter image description here

empty and Click Add.

ASP.NET CORE 7

Upvotes: 2

Related Questions