1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using Microsoft.EntityFrameworkCore;
- using TestUtils.DataAccess.Models;
-
- namespace TestUtils.DataAccess
- {
- public partial class LuUtilsDbContext : DbContext
- {
- private readonly string _connectionString;
-
- public LuUtilsDbContext()
- {
- }
-
- public LuUtilsDbContext(string connectionString)
- {
- _connectionString = connectionString;
- }
-
- public LuUtilsDbContext(DbContextOptions options) :base(options)
- {
- }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (_connectionString != null) {
- optionsBuilder.UseNpgsql(_connectionString);
- }
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
-
- modelBuilder.Entity<fk_pk_guids>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<fk_pk_guids>()
- .Property(e => e.id)
- .HasDefaultValueSql("get_uuid()");
-
-
- modelBuilder.Entity<fk_pk_guids>()
- .HasOne(e => e.fk_pk_guid)
- .WithMany(e => e.fk_pk_guids_fk)
- .HasForeignKey("pk_guid_id")
- .HasConstraintName("fk_pk_guid_pk_guid_id_fkey");
-
-
- modelBuilder.Entity<pk_bigserial>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<pk_bigserial>()
- .Property(e => e.id)
- .HasDefaultValueSql("nextval('pk_bigserial_id_seq'::regclass)");
-
- modelBuilder.Entity<pk_bigserial>()
- .Property(e => e.created_at)
- .HasDefaultValueSql("now()");
-
-
-
- modelBuilder.Entity<pk_guid>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<pk_guid>()
- .Property(e => e.id)
- .HasDefaultValueSql("get_uuid()");
-
- modelBuilder.Entity<pk_guid>()
- .Property(e => e.created_at)
- .HasDefaultValueSql("now()");
-
-
-
- }
-
- public virtual DbSet<fk_pk_guids> fk_pk_guids { get; set; }
-
- public virtual DbSet<pk_bigserial> pk_bigserial { get; set; }
-
- public virtual DbSet<pk_guid> pk_guid { get; set; }
-
- }
- }
|