Description
I've gone through this for several tries and I am getting the same result.
The autogenerated name in the
Add Razor Pages using Entity Framework (CRUD) dialogue,
RazorPagesMovie.Data.RazorPagesMovieContext,
is not being used by the scaffolding as shown in my output window:
C:\Program Files\dotnet\dotnet.exe scaffold aspnet razorpages-crud --model Movie --dataContext RazorPagesMovieContext --dbProvider sqlserver-efcore --page CRUD --project "C:\Tutorials\ASPNetCore\10\RazorPages\RazorPagesMovie\AddAModel\RazorPagesMovie\RazorPagesMovie\RazorPagesMovie.csproj"
Initializing scaffolding model...
Adding package 'Microsoft.EntityFrameworkCore.Tools (v10.0.10)'...
Done
Adding package 'Microsoft.EntityFrameworkCore.SqlServer (v10.0.10)'...
Done
Adding RazorPagesMovieContext.cs...
Done
Updated 'appsettings.json' with connection string 'RazorPagesMovieContext'
Adding Razor page files (.cshtml and .cshtml.cs)...
Done
Updating project 'RazorPagesMovie'...
Done
As a result, my Program.cs has quite a few differences from the Program.cs file in the tutorial.
The tutorial:
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RazorPagesMovie.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
var app = builder.Build();
Mine:
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.");
builder.Services.AddDbContext(options => options.UseSqlServer(connectionString));
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
I end up missing the
using Microsoft.Extensions.DependencyInjection namespace.
Also, the Add Razor Pages using Entity Framework (CRUD) dialogue in tutorial still has the options section, but apparently there is no longer an options section on that screen.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-10.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/model.md
Document ID
7096fdb3-612e-9e00-bd0b-8ea4886a09ce
Platform Id
9d8be74a-08f0-471e-d9da-247aa11a5b2c
Article author
@wadepickett
Metadata
- ID: 6719f08e-3bd7-dc1a-71df-f2ef9fbca9d8
- PlatformId: 9d8be74a-08f0-471e-d9da-247aa11a5b2c
- Service: aspnet-core
- Sub-service: tutorials
Related Issues
Description
I've gone through this for several tries and I am getting the same result.
The autogenerated name in the
Add Razor Pages using Entity Framework (CRUD) dialogue,
RazorPagesMovie.Data.RazorPagesMovieContext,
is not being used by the scaffolding as shown in my output window:
C:\Program Files\dotnet\dotnet.exe scaffold aspnet razorpages-crud --model Movie --dataContext RazorPagesMovieContext --dbProvider sqlserver-efcore --page CRUD --project "C:\Tutorials\ASPNetCore\10\RazorPages\RazorPagesMovie\AddAModel\RazorPagesMovie\RazorPagesMovie\RazorPagesMovie.csproj"
Initializing scaffolding model...
Adding package 'Microsoft.EntityFrameworkCore.Tools (v10.0.10)'...
Done
Adding package 'Microsoft.EntityFrameworkCore.SqlServer (v10.0.10)'...
Done
Adding RazorPagesMovieContext.cs...
Done
Updated 'appsettings.json' with connection string 'RazorPagesMovieContext'
Adding Razor page files (.cshtml and .cshtml.cs)...
Done
Updating project 'RazorPagesMovie'...
Done
As a result, my Program.cs has quite a few differences from the Program.cs file in the tutorial.
The tutorial:
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RazorPagesMovie.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
var app = builder.Build();
Mine:
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.");
builder.Services.AddDbContext(options => options.UseSqlServer(connectionString));
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
I end up missing the
using Microsoft.Extensions.DependencyInjection namespace.
Also, the Add Razor Pages using Entity Framework (CRUD) dialogue in tutorial still has the options section, but apparently there is no longer an options section on that screen.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-10.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/model.md
Document ID
7096fdb3-612e-9e00-bd0b-8ea4886a09ce
Platform Id
9d8be74a-08f0-471e-d9da-247aa11a5b2c
Article author
@wadepickett
Metadata
Related Issues