123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Microsoft.EntityFrameworkCore;
- using WebApiWebSem.DataAccess.Models;
-
- namespace WebApiWebSem.DataAccess
- {
- public partial class WsDbContext : DbContext
- {
- public WsDbContext(DbContextOptions options) :base(options)
- {
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
-
- modelBuilder.Entity<articles>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<articles>()
- .Property(e => e.created_at)
- .HasDefaultValueSql("now_utc()");
-
-
-
- modelBuilder.Entity<articles_fields>()
- .HasKey(c => new { c.article_id, c.property });
-
-
- modelBuilder.Entity<articles_fields>()
- .HasOne(e => e.fk_articles)
- .WithMany(e => e.articles_fields_fk)
- .HasForeignKey("article_id")
- .HasConstraintName("articles_fields_article_id_fkey");
-
-
- }
-
- public virtual DbSet<articles> articles { get; set; }
-
- public virtual DbSet<articles_fields> articles_fields { get; set; }
-
- }
- }
|