【发布时间】:2018-11-15 15:47:50
【问题描述】:
我有一个使用身份数据库来存储用户和客户的应用程序。
每个客户还有一个单独的数据库及其数据,其连接字符串存储在身份数据库的Customer 表中。
AspNetUsers 有一个字段来告诉用户属于哪个客户(也是身份数据库)。
我想在用户登录时为其分配连接字符串,并在会话期间使其在应用程序中可用。
我目前有客户模型:
public partial class `Customer`
{
public int Id { get; set; }
public string Name { get; set; }
public int NoLicenses { get; set; }
public bool? Enabled { get; set; }
public string CustomerConnectionString { get; set; }
}
和用户模型:
public class ApplicationUser : IdentityUser
{
public string CustomerId { get; set; }
public bool? IsEnabled { get; set; }
// there ideally I'd have a connstring property
}
模型映射数据库表字段。
我正在使用 .NET Core 1.1 和 EF Core。
【问题讨论】:
标签: .net-core asp.net-identity multi-tenant dbcontext asp.net-core-1.1