Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aspnetcore/tutorials/razor-pages/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ The next tutorial explains the created files.
The scaffold process adds the following highlighted code to the `Program.cs` file:

# [Visual Studio](#tab/visual-studio)
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_all&highlight=1-3,8-9)]
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_all&highlight=1,3,5)]
Comment thread
guardrex marked this conversation as resolved.
Comment thread
guardrex marked this conversation as resolved.

# [Visual Studio Code](#tab/visual-studio-code)
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_all_sl&highlight=1-3,8-9)]
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_all_sl&highlight=1-3,8,9)]
Comment thread
guardrex marked this conversation as resolved.

---

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// <snippet_all>
// <snippet_di>
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RazorPagesMovie.Data;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.");

builder.Services.AddDbContext<RazorPagesMovieContext>(options => options.UseSqlServer(connectionString));
Comment thread
guardrex marked this conversation as resolved.

// Add services to the container.
builder.Services.AddRazorPages();
Comment thread
guardrex marked this conversation as resolved.
builder.Services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
// </snippet_di>

var app = builder.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// <snippet_all>
// <snippet_di>
using Microsoft.EntityFrameworkCore;
using RazorPagesMovie.Data;
using RazorPagesMovie.Models;

var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.");

builder.Services.AddDbContext<RazorPagesMovieContext>(options => options.UseSqlServer(connectionString));
Comment thread
guardrex marked this conversation as resolved.
Comment thread
guardrex marked this conversation as resolved.

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));

var app = builder.Build();

Expand All @@ -20,11 +20,12 @@

SeedData.Initialize(services);
}
Comment thread
guardrex marked this conversation as resolved.
// </snippet_di>

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

Expand All @@ -35,34 +36,31 @@
app.UseAuthorization();

app.MapStaticAssets();
app.MapRazorPages();
app.MapRazorPages()
.WithStaticAssets();

app.Run();

// </snippet_all>
#elif SQL_Lite
// <snippet_all_sl>
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RazorPagesMovie.Data;
using RazorPagesMovie.Models;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlite(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));

var app = builder.Build();

using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;

SeedData.Initialize(services);
}

// Configure the HTTP request pipeline.
Comment thread
guardrex marked this conversation as resolved.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

Expand Down
4 changes: 2 additions & 2 deletions aspnetcore/tutorials/razor-pages/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ The `RazorPagesMovieContext` object handles the task of connecting to the databa

# [Visual Studio](#tab/visual-studio)

[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_di&highlight=8-9)]
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_di&highlight=5)]
Comment thread
guardrex marked this conversation as resolved.

# [Visual Studio Code](#tab/visual-studio-code)

[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_di_sl&highlight=7-8)]
[!code-csharp[](~/tutorials/razor-pages/razor-pages-start/snapshot-sample10/Program.cs?name=snippet_di_sl&highlight=8-9)]

---

Expand Down
Loading