ADO.NET实体模型连接字符串问题
显然,设计器类的代码生成器 EntityModelCodeGenerator 使用“实体容器名称”(模型的一个属性)作为连接字符串的名称;这意味着设计器类中具有命名连接字符串参数的模型构造函数将始终使用实体容器名称生成。 比如:
public MyEntities() :
base("name=MyEntities", "MyEntities")
{
this.OnContextCreated();
}
现在我知道可能会有很多赞成和反对的争论,但我只是好奇为什么会有这个限制?为什么连接字符串的名称不能与实体容器的名称不同?出于某种原因,我可能会选择使用连接到同一数据库的 2 个模型...... 或者我弄错了,有一种方法可以以不同的方式配置这两个,在这种情况下,如果有人告诉我如何做,我将不胜感激?
提前致谢 尤利安
Apparently the code generator for the designer class, EntityModelCodeGenerator that is, uses the "Entity Container Name", a property of the model, for the name of the connectionstring; meaning that the model constructor in the designer class that has the named connection string parameter will always be generated using the Entity Container Name.
Something like:
public MyEntities() :
base("name=MyEntities", "MyEntities")
{
this.OnContextCreated();
}
Now I know there can be a lot of pro and con arguments, but I was just curious why this constraint? Why can I not have the connecton string with a different name than the entity container? For some reason I might chose to work with 2 models connected to the same database...
Or did I get it wrong, and there is a way to configure these two differently, in which case I would appreciate if someone will tell me how?
Thanks in advance
Iulian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论