builder.Services.AddApp(info =>
{
// ...
// 在此配置多个数据库连接
info.Connections = [
new Known.ConnectionInfo
{
Name = "Default", // 框架默认数据库名称不能修改
DatabaseType = DatabaseType.SQLite,
ProviderType = typeof(Microsoft.Data.Sqlite.SqliteFactory),
ConnectionString = builder.Configuration.GetSection("ConnString").Get<string>()
},
new Known.ConnectionInfo
{
Name = "BizDB1", // 业务数据库1
DatabaseType = DatabaseType.SqlServer,
ProviderType = typeof(System.Data.SqlClient.SqlClientFactory),
ConnectionString = builder.Configuration.GetSection("ConnStringBiz1").Get<string>()
}
];
});
var db1 = Database.Create("BizDB1");