2017-09-22 3 views
0

MVC 프로젝트를 배우는 중입니다. 이제 게시 방법을 배우려고합니다. 연결 문자열을 구성해야하는 곳에서이 문제가 발생했습니다. 아무 것도 생각하지 않습니다. 내 web.config에서 누락되었습니다. 게시 용 연결 문자열이 누락되었습니다.

내가 그것을 추가해야하거나 (하나를 추가하려고했지만, 난 여전히 좋은하지 메신저 때문에 더 문제가 발생하지 않도록 먼저 요청하거나 연구를 할 생각)? 다른 곳에서 찾을 수 있습니다

웹 마십시오. 설정

<?xml version="1.0" encoding="utf-8"?> 
<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> 
<appSettings> 
<add key="webpages:Version" value="3.0.0.0"/> 
<add key="webpages:Enabled" value="false"/> 
<add key="ClientValidationEnabled" value="true"/> 
<add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
</appSettings> 
<system.web> 
<compilation debug="true" targetFramework="4.6.1"/> 
<httpRuntime targetFramework="4.6.1"/> 
</system.web> 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/> 
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> 
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/> 
    </dependentAssembly> 
</assemblyBinding> 
</runtime> 
<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> 
<system.web> 
<customErrors mode="Off"/> 
</system.web> 
</configuration> 
+1

web.config에 추가해야합니다. Thibault

답변

1

예를 들어, <configSections> 태그에 <configuration> 요소, 병렬 내에서 섹션을 추가 :

<configuration> 
    <connectionStrings> 
     <add name="DbConnection" connectionString="Data Source=(localdb)\v11.0;Initial Catalog=randomDatabaseName;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
</configuration> 

를 앱에, 당신은을 호출 할 수 있습니다 DbConnection : 선언 된 이름을 사용하여 데이터베이스. 그리고 원하는만큼이 섹션에 많은 연결 문자열을 추가 할 수 있습니다.

질문에 대답하기 위해 필요할 때마다 실제로 문자열을 직접 구성하거나 구성 파일에 쓸 수 있습니다. entityframework를 사용하는 경우 web.config에 연결 문자열을 넣는 것이 더 이상 필요하지 않다고 생각합니다.

관련 문제