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