-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
29 lines (21 loc) · 851 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Api;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
// Entity Framework.
var connectionString = builder.Configuration.GetConnectionString("Default");
builder.Services
.AddPooledDbContextFactory<ApplicationDbContext>(
options => options
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))
.EnableDetailedErrors(builder.Environment.IsDevelopment())
.EnableSensitiveDataLogging(builder.Environment.IsDevelopment()));
// --
var app = builder.Build();
// Reproduction.
app.MapGet("/", (IDbContextFactory<ApplicationDbContext> dbContextFactory) =>
{
var dbContext = dbContextFactory.CreateDbContext();
var title = "title";
return dbContext.Articles.Where(a => a.Title == title);
});
app.Run();