I try to create an EntityFramework Core's model with an existing database (doc here : https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html) but I have an error.
When I try the Package Manager method, I have the error :
The term "MY_DATABASE_NAME" is not recognize as a valid command applet [...]
This is the command I execute :
Scaffold-DbContext "'MY_CONNECTION_STRING'" Microsoft.EntityFrameworkCore.SqlServer -outputDir MY_PATH -verbose
And when I try the Command Prompt method, I have this error :
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Object reference not set to an instance of an object.
Here the command I execute :
dotnet ef dbcontext scaffold "'MY_CONNECTION_STRING'" Microsoft.EntityFrameworkCore.SqlServer -outputDir MY_PATH -verbose
Before this question, I checked :
- If I have installed good packages (Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.SqlServer.Design)
- If my project.json was correct (tools, ...)
- If my database was online, with good credentials
Succeed with command prompt :
Command :