Unable to find provider assembly 'Microsoft.EntityFrameworkCore.SqlServer'. Ensure the name is correct and it's referenced by the project

2.4k views Asked by At

Please can you tell me how I solve this problem?

Code to scaffold:

scaffold-dbcontext "server=.\DESKTOP-UO195S8; database=BooksDB; integrated security=false;User ID=sa;Password=shvi" 
         Microsoft.EntityFrameworkcore.sqlserver -OutputDir models
1

There are 1 answers

0
Bellash On BEST ANSWER

SHORT SOLUTION: downgrade to version 3.1.15 of everything of .net core 3.1 assemblies (2022 update: you also may need to upgrade to the latest version available)

EXPLANATION: You should check if you have the same version of Microsoft.VisualStudio.Web.CodeGeneration.Design as you current version of Microsoft.EntityFrameworkCore.SqlServer. For some unknown reasons, the last stable version of Microsoft.VisualStudio.Web.CodeGeneration.Design is 3.1.15 while the default stable version of Microsoft.EntityFrameworkCore.SqlServer is currently 3.1.18 (see picture 1)

Therefore, when you run the scolding command, it tries to install a version which really is not compatible with the versions inside your project(possibly)

stable Microsoft.VisualStudio.Web.CodeGeneration.Design

Vs

stable Microsoft.EntityFrameworkCore.SqlServer

Downgrading to 3.1.15 and bob is your uncle