dotnet / dotnet/AspNetCore.Docs

Improvements for eager novices?

Open
#27,765 1 comment 0 reactions 1 assignee Claimed by @wadepickett View on GitHub
doc-enhancement Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

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
* Content: [Part 4, work with a database](https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-7.0&tabs=visual-studio)
* Content Source: [aspnetcore/tutorials/razor-pages/sql.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/sql.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-tutorials**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.