aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Creating Edit View with Non EFModel #1096

Open GaryFurash opened 4 years ago

GaryFurash commented 4 years ago

Using latest ASP.NET Core with latest Nuget on Visual Studio 2019 windows 10 pro.

If I try to create an Edit view based on a view model that isn't configured in the DB context (e.g., it's a model that doesn't map to a DB table in EF), even after adding the [Key] annotation I get the error:

'The entity type 'RoleEdit' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'.'

I can't use HasNoKey since the model entity isn't in the context since it isn't a real table.