dotnet / dotnet/Scaffolding

Can't get CRUD scaffolding to work after running Reverse Engineer from EF Core Power Tools, throws breaking error

Open
#2,625 2 comments 0 reactions 0 assignees View on GitHub
area-scaffolding customer-reported
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

_NOTE: I've already requested help from Erik, the author of EF Core Power Tools. He closed my ticket (with no additional help) and sent me here._

I am trying something that appears very straight-forward, but am getting stuck. Maybe I'm not using the correct process?

High-level description: I have an existing DB with two tables and a single SP. I can reverse engineer the DB using EFPowerTools and operation completes without issue. However, if I then try to scaffold a new page based on one of the created Models, I get an error: "**Error - There was an error running the selected code generator: 'Could not get the reflection type for DbContext : EFPowerToolsDemo.Data.DemoDbContext'** ". I'm not sure how to proceed. Full details are below.

Provide steps to reproduce a bug

- Created new project using "ASP.NET Core Web App (Razor Pages) template. Using .Net 8.0 (LTS) with no authentication type. Built project to verify code. Added "Models" and "Data" folders to root project.
- Right-clicked on project name, EF Core Power Tools => Reverse Engineer. Choose the DB and EF Core version of 8.0. Picked the two tables and the SP. Set "EntityTypes path" to Models. Checked "Use DataAnnotation attributes to configure the model". Under Advanced... added Data folder to DbContext path. Click okay, let it run, then built the project to verify all the new code is functional.
- Add 'NewPage' folder under Pages. Right-click on the new folder and Add => New Scaffolding Item... and then pick the Razor Pages using Entity Framwork (CRUD) option. Set Model class to generated model. Set DbContext class to generated context. Hit "add" and code creation starts, but error is thrown during process that ends the operation.
- **Error - There was an error running the selected code generator: 'Could not get the reflection type for DbContext : EFPowerToolsDemo.Data.DemoDbContext'**

Provide technical details

EF Core Power Tools version: 2.6.72

Exact Visual Studio version: Microsoft Visual Studio Professional 2022 (64-bit) - Current, Version 17.8.5

Database engine: SQL Server Enterprise (GA)

EF Core version in use: EF Core 8

I tried this from scratch twice to make sure I didn't miss anything.

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Reproduce the reported setup with the ASP.NET Core Razor Pages .NET 8 template, EF Core Power Tools reverse engineering, and the Razor Pages Entity Framework CRUD scaffolder, using the generated model and DbContext. Done means the CRUD scaffolding completes without the reported DbContext reflection error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.