将连接字符串存储在 WCF 数据服务的服务配置中

发布于 2024-12-07 03:17:52 字数 298 浏览 6 评论 0原文

我有一个类库项目,其中包含指向 SQL Azure 数据库的 EF 模型。我还有另一个 Azure WCF Web 角色项目,其中包含 WCF 数据服务,将 SQL Azure DB 中的数据公开为 OData 服务。现在,我将连接字符串存储在 WCF Web 角色项目的 web.config 中。

我想做的是将其作为配置,因此将其移至服务配置文件,以便我可以在必要时更改连接字符串(将其放在 web.config 中似乎是短视的)。

我遇到的问题是如何连接 OData 服务以不使用 web.config 连接字符串,而是使用配置中的连接字符串。

I've got one class library project that contains an EF model that points to a SQL Azure database. I also have another Azure WCF Web Role project that contains a WCF Data Service exposing the data in my SQL Azure DB as a OData service. Right now I have the connection string stored in the web.config of the WCF Web Role project.

What I'd like to do is make this a configuration, so move it over to the service configuration files so I can change the connection string if necessary (putting it in the web.config seems shortsighted).

The problem I'm having is how to wire the OData service up to not use the web.config connection string but instead use one from the configuration.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁虫ゝ 2024-12-14 03:17:53
RoleEnvironment.GetConfigurationSettingValue(NameofSetting);

???

RoleEnvironment.GetConfigurationSettingValue(NameofSetting);

???

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文