.net - azure辅助角色中的DbConfiguration.SetConfiguration

标签 .net entity-framework azure entity-framework-6 azure-worker-roles

我有一个派生自 DbConfiguration 的类,用于执行任何连接弹性策略。

我在 global.asax.cs 的 Application_Start 中的 Web 角色中调用它。

如果是 worker 角色,我在哪里调用相同的函数?

最佳答案

在应用程序的 app.config 中(我的应用程序名为“WebJob”),其中包含标签 --EntityFramework-- ... 添加 codeConfigurationType,如下所示:

<entityFramework codeConfigurationType="WebJob.EFConfigDB, WebJob">
... your EF config here ...
</entityFramework>

EFConfigDB 是我从 DbConfiguration 派生的类。所以 codeConfigurationType 基本上是这样的格式,这取决于您的项目:

codeConfigurationType="<MyNameSpace>.<Derived DBConfiguration class>, <MyAssembly>"

一旦正确设置了上述内容,您的 DBConfiguration 派生类的无参数构造函数将被自动调用。

关于.net - azure辅助角色中的DbConfiguration.SetConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25723978/

相关文章:

Azure 服务计划和非生产槽

.net - 如何将 Enum 与其他选项一起使用(全部、无)

C#:强制编译器在使用 myObj.ToString() 时出错

c# - 符号已创建,但调试永远不会在断点处停止

c# - 如何重构对服务层的 RIA 数据服务调用?

c# - Entity Framework 6.1 : Multiple added entities may have the same primary key

azure - 负载均衡器如何决定如何路由请求?

c# - 寻找在 WPF 中显示数据行的最简单方法

c# - EF 迁移中的原始 SQL

azure - 有没有办法使用 API 监控 Azure Kubernetes 服务的资源运行状况