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
Get a database context instance from the dependency injection (DI) container.
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.
ID: 03221075-5dfa-d1b6-0552-3fe88abe1d03
Version Independent ID: b8c7d824-35ca-68fb-e3be-839ae886657c
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.