[Common issues] Entity Framework Core: Database-First

while you are trying to generate context using Scaffold-DbContext you may get some errors.

we will list these issues and the solution for them:


1.Scaffold-DbContext Build failed

      make sure that your entire solution has build successfully before run Scaffold-DbContext

2.'Scaffold-DbContext'  Could not load assembly. Ensure it is referenced by the startup project

     here you have two options:
               a. set your project as a startup project.
               b. reference the project dll into the startup project.

3.Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again

     here you should install Microsoft.EntityFrameworkCore.Design package by run the following command in Tools –> NuGet Package Manager –> Package Manager Console

            Install-Package Microsoft.EntityFrameworkCore.Design

4.Scaffold-DbContext : The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.


use the following link to solve this issue: EF - The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet

  


Latest


EmoticonEmoticon