You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
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<WeatherForecastService>();
|
|
|
|
//EF Core
|
|
var connectString = builder.Configuration.GetConnectionString("SQLServer");
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddDbContextFactory<AppDbContext>
|
|
(
|
|
b => b.UseSqlServer(connectString).EnableSensitiveDataLogging(), ServiceLifetime.Scoped
|
|
);
|
|
|
|
builder.Services.AddDbContextFactory<AppDbContext>(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();
|
|
}
|
|
}
|
|
} |