-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (32 loc) · 1.07 KB
/
Program.cs
File metadata and controls
43 lines (32 loc) · 1.07 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace JitCrashPoc;
public class Program
{
public static async Task Main(string[] args)
{
var services = new ServiceCollection();
services.AddDbContext<ClientDbContext>((serviceProvider, options) =>
{
options.EnableDetailedErrors();
options.UseSqlite($"Data Source=:memory:");
});
var sp = services.BuildServiceProvider();
using var scope = sp.CreateScope();
var cctx = scope.ServiceProvider.GetService<ClientDbContext>();
Console.WriteLine("executing");
await cctx.Database.OpenConnectionAsync();
await cctx.Database.MigrateAsync();
await cctx.example_table.AddAsync(new example_table
{
col_1 = 1
});
await cctx.SaveChangesAsync();
var rows = await cctx.example_table.ToListAsync();
foreach (var item in rows)
{
Console.WriteLine(item.col_1);
}
Console.WriteLine("executed");
}
}