-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNosCoreContext.cs
More file actions
40 lines (32 loc) · 1.19 KB
/
NosCoreContext.cs
File metadata and controls
40 lines (32 loc) · 1.19 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
// __ _ __ __ ___ __ ___ ___
// | \| |/__\ /' _/ / _//__\| _ \ __|
// | | ' | \/ |`._`.| \_| \/ | v / _|
// |_|\__|\__/ |___/ \__/\__/|_|_\___|
// -----------------------------------
using Microsoft.EntityFrameworkCore;
using NosCore.Dao.Extensions;
namespace NosCore.PathFinder.Gui.Database
{
public class NosCoreContext : DbContext
{
public NosCoreContext(DbContextOptions options) : base(options)
{
}
public virtual DbSet<Map>? Map { get; set; } = null!;
public virtual DbSet<MapMonster>? MapMonster { get; set; } = null!;
public virtual DbSet<MapNpc>? MapNpc { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// remove automatic pluralization
modelBuilder.RemovePluralizingTableNameConvention();
modelBuilder.Entity<Map>()
.HasMany(e => e.MapMonster)
.WithOne(e => e.Map)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Map>()
.HasMany(e => e.MapMonster)
.WithOne(e => e.Map)
.OnDelete(DeleteBehavior.Restrict);
}
}
}