123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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<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<pk_bigserial> pk_bigserial { get; set; }
-
- public virtual DbSet<pk_guid> pk_guid { get; set; }
-
- }
- }
|