<分区>
如何让单个 C# 应用程序具有管理多个模式的 Entity Framework ?或者应该是单一架构?
我有大约 28 个客户,我想知道我是将每个客户都保留在一个单独的数据库中,还是统一在一个数据库中,并且我管理客户 ID 等信息。
我担心数据量会影响应用程序性能。我目前使用的SQL Server 2014各有一个版本的系统,我们正在演进系统,希望适合最好的场景。
个人认为由客户端访问登录控制的单体应用,最好给予维护。
我不知道是否可以有单独的数据库,因为我有一些客户喜欢在他们的服务器中对他们自己的模式进行安全管理。
如何创建动态获取连接字符串的上下文,取决于 关于请求的来源?
public class ProductRepository {
public void Add(Product product, int clientId)
{
//Here the connection string will be set according to the client id you are saving information
var context = ContextFactory.GetContext(clientId);
context.Products.Add(product);
}
}
还是放在属于信息的实体客户 ID 中更好?
public class BaseEntity {
public int Id {get;set;}
public int Client_Id {get;set}
}
public class Products : BaseEntity{
public string Name {get;set;}
public double Price {get;set;}
}