-
Notifications
You must be signed in to change notification settings - Fork 1
/
Context.cs
35 lines (31 loc) · 901 Bytes
/
Context.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
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EFTest
{
public class Context : DbContext
{
public Context() : base() { Init(); }
public Context(string nameOrConnectionString) : base(nameOrConnectionString) { Init(); }
public void Init()
{
this.Database.Log = (s) => {
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(s);
Console.ResetColor();
};
Database.SetInitializer < Context > (null);
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Configurations.Add(new ProductSchema());
modelBuilder.Configurations.Add(new PersonSchema());
modelBuilder.Configurations.Add(new SellerSchema());
modelBuilder.Configurations.Add(new BuyerSchema());
}
}
}