ASP.NET Core Scaffolding Bug for separated projects

A quick fix for ASP.NET Core Scaffolding Bug for separated DbContext & Model.


Project structure:

├── Solution
│   └── BL
│   │   ├── Database
│   │   └── DbContext
│   └──Core
│   │   └── Models
│   │       ├──ApplicationInfo
│   │       ├── VersionInfo
│   │       └── ApplicationInfo
│   └── WebApp
│   │   └── Controllers
│   │       └── ApplicationInfoesController
│ …

When DbContext and Models are placed in separated projects from the main WebApplication, like the one above, Scaffolding will prompt the following error:

Scaffolding error

This issue is being addressed and the patch is releasing soon (hopefully) in Scaffolding v2.0.3.

Meanwhile, a quick fix is to supply full qualifier name into DbSet:

// This will not work

public DbSet<VersionInfo> VersionInfos { get; set; }

// Full model qualifiers must be used in order for Scaffolding to succeed

public DbSet<Core.Models.DbModels.ApplicationInfo> ApplicationInfos { get; set; }
Last updated