You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
805 B
20 lines
805 B
using Microsoft.EntityFrameworkCore;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
namespace CockRoachDBEntityFrameworkCoreTest
|
|
{
|
|
public class MyDbContext : DbContext
|
|
{
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
//数据库名只能为小写,否则报错为:database "postgres" does not exist
|
|
optionsBuilder.UseNpgsql("User ID=root;Host=localhost;Port=26257;Database=mytest;CommandTimeout=120;SslMode=Require;TrustServerCertificate=true;",
|
|
o => o.ProvideClientCertificatesCallback(o => o.Add(new X509Certificate2("client.root.pk12"))));
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<User>();
|
|
}
|
|
}
|
|
} |