12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using Microsoft.EntityFrameworkCore;
- using Luticate2.Auth.DataAccess.Models;
- using Test.Utils.DataAccess.Models;
-
- namespace Test.Utils.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; }
-
- }
- }
|