.Net Core Api EntityFrameworkCor
2020-07-20 本文已影响0人
谢冰Drama
设置多连接字符串 意在 可以 有多个从库 进行 随机访问

下面是 具体的方法
(这里我采用了随机, 也可以扩展成 权重 或者 其他 比如 hash)

这里是连接字符串 (这里采用注入的方式)

这是连接字符串的实现类 (也可以用静态类)

这里是在ConfigureService 进行注入

以下是运行结果:

设置多连接字符串 意在 可以 有多个从库 进行 随机访问
下面是 具体的方法
(这里我采用了随机, 也可以扩展成 权重 或者 其他 比如 hash)
这里是连接字符串 (这里采用注入的方式)
这是连接字符串的实现类 (也可以用静态类)
这里是在ConfigureService 进行注入
以下是运行结果: