学习MVC3,连接字符串

时间:2011-10-09 23:42:58

标签: asp.net-mvc asp.net-mvc-3 connection-string

我通过报道着名的MusicStore教程http://mvcmusicstore.codeplex.com/来学习MVC3 首先用于EF代码的连接字符串是:

<connectionStrings>
    <add name="MusicStoreEntities"
    connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
    providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

我想使用我的localhost SQL Server数据库(Windows身份验证)。它能保持正常工作的连接字符串是什么?谢谢,

2 个答案:

答案 0 :(得分:3)

假设您的数据库名称为MusicStore

ConnectionString="Data Source=(local); Initial Catalog=MusicStore; Integrated Security=True;"
Provider="System.Data.SqlClient"

答案 1 :(得分:1)

下面:

<add name="MusicStoreEntities" connectionString="DATA SOURCE =(Your Server Name); INITIAL CATALOG =MusicStore;Integrated Security=True;" providerName="System.Data.SqlClient"/>

并查看

Connection strings for SQL Server 2008

此致