Open doggy8088 opened 4 years ago
If the context does not exist, we create one for the model class specified.
@deepchoudhery I think the appsettings.json
shouldn't be touched if the code generation fail.
@deepchoudhery by the way, the default output directory of the created data context class is Data/
. Is it possible add an new option to change the default?
@deepchoudhery I think the appsettings.json shouldn't be touched if the code generation fail.
Yep that makes sense. I'll take a look at that.
@deepchoudhery by the way, the default output directory of the created data context class is Data/. Is it possible add an new option to change the default?
Does not exist currently, but I could look at this in a servicing update.
Steps to reproduce:
dotnet new webapi -n api1 && cd api1
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet tool update -g dotnet-ef
dotnet ef dbcontext scaffold "Server=(localdb)\MSSQLLocalDB;Database=ContosoUniversity;Trusted_Connection=True;MultipleActiveResultSets=true" Microsoft.EntityFrameworkCore.SqlServer -o Models -f
dotnet aspnet-codegenerator controller -name CoursesController -async -api -m Course -dc myContext -outDir Controllers
Expected behavior:
I expected to get an error, it because there is no
myContext
in my project.Actual behavior:
The log message said below. In fact, there is no
myContext
been created in the project.Also, there is a
ConnectionStrings
calledmyContext
has been added to theappsettings.json
. What is this for?Additional information about the project being scaffolded, such as:
Target framework(s):
.NET Core 3.1
Package version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All (if applicable):
Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding: