Condividi tramite

Problems in scaffolding db iwith EntityFarmeworkCore 8.0

leo del ciello 106 Punti di reputazione
2025-10-14T08:35:25.4733333+00:00

I am trying to scaffold the "AdventureWorks" db in my .net 8.0 web api application using EntityFramweworkCore 8.0. I keep having the following warning : " Your startup project 'TestServer' 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."

even if I have correctly installed Microsoft.EntityFrameworkCore.Design and referenced it in my project. As far as I can see, the packagge is correctly installed since it appears between the references. Moreover I set my project as the Startup Project as advised in many articles. I uninstalled and reinstalled Microsoft.EntityFrameworkCore.Design at least three times before giving up . What should I do to solve the problem, and more importanlty, can it be solved or should I give up using EntityFrameworkCore ?

Tecnologie per sviluppatori | ASP.NET | Altro
0 commenti Nessun commento
{count} voti

Risposta accettata dall'autore della domanda
  1. Raymond Huynh (WICLOUD CORPORATION) 3,645 Punti di reputazione Personale Esterno Microsoft Moderatore
    2025-10-14T09:21:42.6066667+00:00

    Hi leo del ciello ,

    That issue is actually quite common and usually not related to your setup.

    There’s a known EF Core 8 issue that can cause scaffolding to fail with a NullReferenceException when the database contains certain table names, for example, a table called Properties. The process starts normally but crashes during model generation.

    #My recommendations:

    • Scaffold only specific tables first Try generating models for just a few tables instead of the entire database to confirm the issue. Scaffold-DbContext "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables Product, Address, Customer
    • Use the .NET CLI The command-line tool sometimes works better than the Package Manager Console: dotnet ef dbcontext scaffold "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -o Models
    • Try EF Core Power Tools This Visual Studio extension can scaffold your database in a different way and may avoid the same bug.

    Hope this helps!

    1 persona ha trovato utile questa risposta.

0 risposte aggiuntive

Ordina per: Più utili

Risposta

Le risposte possono essere contrassegnate come "Accettata" dall'autore della domanda e "Consigliata" dai moderatori, in modo da consentire agli utenti di sapere che la risposta ha risolto il problema dell'autore.