-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
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
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
Metadata
- ID: 03221075-5dfa-d1b6-0552-3fe88abe1d03
- PlatformId: 8bd9f515-9a6f-9beb-35ad-1c3221c87116
- Service: aspnet-core
- Sub-service: tutorials