【发布时间】:2012-08-17 12:50:57
【问题描述】:
我是新手,不知道怎么做。
我已经在 Visual Studio 2010 中构建了 MVC 3 应用程序并发布到本地主机,它工作正常。
在这里,我真正想要的是使用安装在我计算机中的 Sql Server 2008,而不是我使用 Visual Studio 创建的文件夹 APP_DATA 下的数据库。
我是 MVC 新手,不了解数据库连接的详细信息。以下是web.config文件的连接字符串:
<connectionStrings>
<add name="IVRControlPanelEntities" connectionString="metadata=res://*/Models.IVRControlPanelModel.csdl|res://*/Models.IVRControlPanelModel.ssdl|res://*/Models.IVRControlPanelModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\IVRControlPanelDB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
这是Visual Studio在添加数据实体模型时自动添加的连接字符串。
发布到 localhost 后,mvc 3 使用的数据库在 wwwroot 文件夹的 APP_DATA 文件夹下。
我需要更改以连接到我的计算机中安装的 Sql Server 2008,而不是在 Visual Studio 上创建的数据库。
还有一件事,我无法将 Visual Studio 创建的数据库导入 IVRControlPanelDB 形式的 sql server 2008。mdf
【问题讨论】:
-
不能直接导入mdf文件。您可以创建一个数据库并附加一个 mdf 文件。
标签: asp.net-mvc-3 sql-server-2008 entity-framework-4 connection-string