AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Must add db context (program.cs) before scaffolding with aspnet-codegenerator
Description
In the section Scaffold movie pages under the tab for Visual Studio Code the instructions are sequenced to first show use of the aspnet-codegenerator CLI, then how to modify Program.cs to configure the context w/ SQLite and SQL Server.
I think the order should be reversed.
If the reader attempts to invoke the aspnet-codegenerator command prior to configuring the context, s/he will get an error like the following
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'Movie'
Unable to create a 'DbContext' of type 'MvcMovie.Data.MvcMovieContext'.
The exception 'Unable to resolve service for type
'Microsoft.EntityFrameworkCore.DbContextOptions`1[MvcMovie.Data.MvcMovieContext]'
...
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-model?view=aspnetcore-8.0&tabs=visual-studio-code
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/first-mvc-app/adding-model.md
Document ID
48e81b42-7c2b-afbf-71e6-d4f442a4bd1f
Article author
@wadepickett