blob: c95a4d0811c33c174aa270c04d6b89fe2c62fd96 (
plain) (
blame)
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
|
using Microsoft.EntityFrameworkCore;
using VSH.Data.Database;
namespace VSH.Data;
public class MainDbContext : DbContext
{
public MainDbContext(DbContextOptions<MainDbContext> options) : base(options) { }
public DbSet<User> Users { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<Document> Documents { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<User>(e => {
e.ToTable("Users");
});
modelBuilder.Entity<Category>(e => {
e.ToTable("Categories");
});
modelBuilder.Entity<Order>(e => {
e.Property(c => c.Products).HasColumnType("jsonb");
e.Property(c => c.ContactInfo).HasColumnType("jsonb");
e.ToTable("Orders");
});
modelBuilder.Entity<Product>(e => {
e.Property(c => c.Images).HasColumnType("jsonb");
e.ToTable("Products");
});
modelBuilder.Entity<Document>(e => {
e.ToTable("Documents");
});
base.OnModelCreating(modelBuilder);
}
}
|