您可以在MSDN: Entity Framework Config File Settings
一個例子web.config中讀取有關配置可以是:
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="MyConnectionString" connectionString="Data Source=MySqlServerInstance;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
</configuration>
來源
2017-10-17 07:28:39
ChW
什麼**版的SQL Server 2016 **是否安裝?你是否在安裝過程中指定了一個實例名稱? SQL Server 2016 ** Express **默認安裝爲'。\ SQLEXPRESS',而其他版本通常安裝爲* default,unnamed *實例(您可以使用'.'或'(local)'作爲您的訪問服務器/實例名稱) –
企業版,並沒有指定任何東西 –
那麼你的連接字符串應該是'Data Source =(local);初始目錄=(你的數據庫名稱);集成安全= SSPI;'或類似的東西 - 你能告訴我們(通過編輯/更新你的問題)你正在使用的是什麼? –