-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMyDbContext.cs
More file actions
49 lines (41 loc) · 1.44 KB
/
Copy pathMyDbContext.cs
File metadata and controls
49 lines (41 loc) · 1.44 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
44
45
46
47
48
49
using BlazarTech.QueryableValues;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace QueryableValues.SqlServer.Benchmarks
{
public class MyDbContext : DbContext
{
private readonly SqlServerSerialization _serializationOption;
public DbSet<Int32Entity> Int32Entities { get; set; } = default!;
public DbSet<GuidEntity> GuidEntities { get; set; } = default!;
public DbSet<StringEntity> StringEntities { get; set; } = default!;
public MyDbContext(SqlServerSerialization serializationOption)
{
_serializationOption = serializationOption;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
@"Server=.\SQLEXPRESS;Integrated Security=true;Database=QueryableValuesBenchmarks;Encrypt=False;",
builder => builder.UseQueryableValues(options => options.Serialization(_serializationOption))
);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("dbo");
}
}
public class Int32Entity
{
public int Id { get; set; }
}
public class GuidEntity
{
public Guid Id { get; set; }
}
public class StringEntity
{
[MaxLength(100)]
public string Id { get; set; } = default!;
}
}