Please enable JavaScript in your browser!
首页
探索
登录
apeart / paste-apeart
master
104
提交
1
分支
0
标签
Copy
/
src
/
PasteApeart.EntityFrameworkCore
/
readwrite
/
readme.md
/
readme.md
文件列表
5 项
..
ConnectionStringSelector.cs
IConnectionStringSelector.cs
ReadWriteSplitInterceptor.cs
UseReadOnlyConnectionAttribute.cs
readme.md
文件内容
readme.md
0 KB
524 字符
## 如何引入 ```csharp services.AddScoped<IConnectionStringSelector, ConnectionStringSelector>(); services.AddSingleton<ReadWriteSplitInterceptor>(); services.AddDbContext<SqliteDb>((sp, options) => { options.UseSqlite(configuration.GetConnectionString(PasteApeartDbProperties.SqliteConnectionStringName)); //读写分离 如果不需要那么用上面的,或者下面2行注释掉即可 var rwp = sp.GetRequiredService<ReadWriteSplitInterceptor>(); options.AddInterceptors(rwp); }); ``` ## 标注特性 然后再需要的地方标注对应特性即可!