问题描述
我正在尝试编写一些代码,允许我在 SQLCE(在我的开发机器上本地)和完整 SQL(在 AppHarbor 上)之间切换.使用SQL CE,连接字符串都为我处理,但我必须为SQL自己构建它.到目前为止,我的代码如下,但是它给出了这个错误:
I'm trying to write some code that allows me to switch between SQLCE (locally on my dev machine) and full SQL (on AppHarbor). With SQL CE, the connection string is all handled for me, but I have to construct it myself for SQL. My code so far is below, however it gives this error:
不支持关键字:'元数据'
Keyword not supported: 'metadata'
我已经在网上找了几个小时,但所有的解决方案都涉及使用我找不到的ContextBuilder"类(我已经通过 NuGet 包安装了 EF).
I've been looking online for hours, but all the solutions involve using a "ContextBuilder" class which I can't find (I've installed EF via the NuGet package).
这是当前代码(通过 WebActivator 在启动时运行):
Here's the current code (running at startup via WebActivator):
推荐答案
你应该使用 EntityConnectionStringBuilder 类
这篇关于如何以编程方式设置实体框架代码优先的连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!