using EFCore7Study.BlazorServerApp.Data; using EFCore7Study.DataService; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; namespace EFCore7Study.BlazorServerApp { public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); //EF Core var connectString = builder.Configuration.GetConnectionString("SQLServer"); builder.Services.AddDbContextFactory ( b => b.UseSqlServer(connectString).EnableSensitiveDataLogging(), ServiceLifetime.Scoped ); builder.Services.AddDbContextFactory(options => options.UseSqlServer(connectString)); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); app.Run(); } } }