Configure Entity Framework to pick connection strings from Azure CloudConfiguration File?

大兔子大兔子 提交于 2020-01-02 09:10:07

问题


We are using EF-6 in our web roles & worker roles. These roles are encapsulated into a single cloud service project.

In order to manage config settings in a better way, we have moved most of our config keys into cloud project & we read them using CloudConfigurationManager.

But for packages like Entity Framework or Enterprise Library we can't tell AppDomain to read settings from Cloud Config file. EF looks into respective App.Config or Web.Config of the project.

Is there any way to tell EF to read connection strings from cloud config file?


回答1:


You could change the T4 template file Model.Context.tt to use

base(CloudConfigurationManager.GetSetting("YourEntities"))

When you regen your model the resulting Model.Context.cs file will use the CloudConfigurationManager.



来源:https://stackoverflow.com/questions/24222862/configure-entity-framework-to-pick-connection-strings-from-azure-cloudconfigurat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!