Adatepd appsettings-Files

This commit is contained in:
Giuseppe D’Ettorre
2026-07-09 17:18:21 +02:00
parent 0e5d5c2a17
commit f2a1efc807
4 changed files with 17 additions and 10 deletions
+1
View File
@@ -3,6 +3,7 @@ using RazorPagesMovie.Data;
using RazorPagesMovie.Models; using RazorPagesMovie.Models;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddJsonFile("appsettings.Local.json", optional: true, reloadOnChange: true);
builder.Services.AddDbContext<RazorPagesMovieContext>(options => builder.Services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found."))); options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
builder.Services.AddRazorPages(); builder.Services.AddRazorPages();
+5 -2
View File
@@ -1,9 +1,12 @@
{ {
"DetailedErrors": true, "DetailedErrors": true,
"ConnectionStrings": {
"RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-bc;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=true"
},
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Debug",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Information"
} }
} }
} }
+7 -1
View File
@@ -1,5 +1,11 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"RazorPagesMovieContext": "Server=sqlserver,1433;Database=RazorPagesMovieContext;User Id=sa;Password=YourPassword123!;TrustServerCertificate=True" "RazorPagesMovieContext": "Server=sqlserver,1433;Database=RazorPagesMovieContext;User Id=sa;Password=YourPassword123!;TrustServerCertificate=True"
},
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore": "Warning"
}
} }
} }
+1 -4
View File
@@ -5,8 +5,5 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*"
"ConnectionStrings": {
"RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-bc;Trusted_Connection=True;MultipleActiveResultSets=true"
}
} }