using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Configuration.Json; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using TCM_API.Models; using TCM_API.Entities; using TCM_API.Models.manage; namespace TCM_API.Services { public class SqlContext : DbContext { public SqlContext(DbContextOptions options) : base(options) { //連接PostgreSQL AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); } //public DbSet e_table_v { get; set; } = null!; //public DbSet test_0525 { get; set; } = null!; // Model名稱 test_0330 SQL名稱 public DbSet user_table { get; set; } = null!; public DbSet company_detail_table { get; set; } = null!; public DbSet health_detail_table { get; set; } = null!; protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); //builder.Entity().HasKey(o => new { o.user_id }); //Primary Key builder.Entity().HasKey(o => new { o.id }); //Primary Key builder.Entity().HasKey(o => new { o.guid }); builder.Entity().HasKey(o => new { o.guid }); } } }