dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.64k stars 25.28k forks source link

Improvements for eager novices? #27765

Open AndrewBS42 opened 1 year ago

AndrewBS42 commented 1 year ago

One portion of this page describes adding the Seed Initializer to the code. It works, but there are a couple of issues that might be tricky for novices.

The discussion mentions the DI container, but doesn't mention that we get to the DI container through the variable 'scope'.

The description mentions that one of the things the modified code does is

That statement is misleading. The modified code actually gets the whole collection of services from the DI container, not just the database context. The whole collection does include the database context, but the type of the object fetched from scope is not a RazorPagesMovieContext. The code is great, but the description is misleading.

Finally, the tutorial includes the statement

The following exception occurs when Update-Database has not been run: SqlException: Cannot open database "RazorPagesMovieContext-" requested by the login. The login failed. Login failed for user 'user name'.

It's great that you're explaining why some learners may see an error when they run the Part 4 code for the first time. I'm sure it saves lots of panic. But you don't mention where Update-Database was run, and Update-Database doesn't appear anywhere else in Part 4. It might be better if you mentioned that Update-Database was run back in Part 2. Then learners would know what to review when they do see that error.

Thanks!

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Rick-Anderson commented 1 year ago

Great suggestions