diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
| commit | 9383a2fb09ffb60cfe63683106945bd688affa59 (patch) | |
| tree | 65b3f4b48841583e355887db5de5a16e7005fc87 /src/Data/MainDbContext.cs | |
| download | vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.tar.xz vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.zip | |
feat: Initial commit after clean slate
Diffstat (limited to 'src/Data/MainDbContext.cs')
| -rw-r--r-- | src/Data/MainDbContext.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Data/MainDbContext.cs b/src/Data/MainDbContext.cs new file mode 100644 index 0000000..c95a4d0 --- /dev/null +++ b/src/Data/MainDbContext.cs @@ -0,0 +1,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); + } +}
\ No newline at end of file |
