Skip to content

Apparent typo in Part 4, Work With a Database => Seed The Database #36420

@phil806-code

Description

@phil806-code

Description

using .NET 9.0

typo: => Seed The Database => SeedData.cs; the following code was wrong (causes context to be undefined):
using (var context = new RazorPagesMovieContext(
serviceProvider.GetRequiredService<
DbContextOptions>()))
it should be:
using var context = new RazorPagesMovieContext(
serviceProvider.GetRequiredService<
DbContextOptions>());

            and at the end should be two end braces not three.

typo: => Seed The Database => Add The Seed Initializer => Program.cs; the following code was wrong:
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
SeedData.Initialize(services);
}
it should be:
using var scope = app.Services.CreateScope();
{
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService();
context.Database.EnsureCreated();
SeedData.Initialize(services);
}
}

using .NET 9.0

Page URL

https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-9.0&tabs=visual-studio

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/sql.md

Document ID

b8c7d824-35ca-68fb-e3be-839ae886657c

Platform Id

8bd9f515-9a6f-9beb-35ad-1c3221c87116

Article author

@wadepickett

Metadata

  • ID: 03221075-5dfa-d1b6-0552-3fe88abe1d03
  • PlatformId: 8bd9f515-9a6f-9beb-35ad-1c3221c87116
  • Service: aspnet-core
  • Sub-service: tutorials

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions