I'm using core 3 and I have included below packages to my project
"Microsoft.EntityFrameworkCore.Design": "5.0.7",
"Microsoft.EntityFrameworkCore.SqlServer": "5.0.7",
"Microsoft.EntityFrameworkCore.Tools": ""5.0.7""
And here is my connection string and I have tested the connection before and it succeeded
"ConnectionStrings": { "bikeStore": "Data Source=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********" }
Now I want to run the Scaffold command as below
Scaffold-DbContext Data Source=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data
And I got below error
Build started...
Build succeeded.
Unable to find provider assembly 'Source=localhost'. Ensure the name is correct and it's referenced by the project.
Here's the Server Explorer and how I connected to my db
What is wrong with my approach?
You can replace Data Source
with Server
and provide the provider flag:
Scaffold-DbContext -Connection "Server=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data