using Microsoft.EntityFrameworkCore; using JWTdemo.Entities; namespace JWTdemo.Services { public class SqlContext : DbContext { public SqlContext(DbContextOptions options) : base(options) { //連接PostgreSQL AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); } public DbSetchatuser { get; set; } = null!; protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity().HasKey(o => new { o.Id }); //Primary Key } } }