2016-06-28 2 views
0

VS 2015 최신 업데이트가 설치되어 있고 모든 패키지가 최신 버전입니다. 그런 다음 데이터베이스에서 코드를 사용하여 데이터 모델을 다시 생성하는 동안 (거의 사용자 지정을 사용하여 T4를 사용함) 거의 모든 시간 동안 오류가 발생했습니다. 전에는이 오류가 없었습니다. 때로는 VS 2015를 다시 시작하거나 워크 스테이션을 재부팅하여이 오류를 해결할 수 있지만 항상 그런 것은 아닙니다. 누구도 같은 문제가 있습니다. 당신의 도움을 주셔서 감사합니다.EF 6 코드 첫 번째 데이터베이스 모델 생성 오류에서

An error occurred generating the Code First model. The error occurred generating the contents of DbCtx.cs. 

System.InvalidOperationException: Compiling transformation: The type ‘DbModel’ exists in both ‘EntityFramework, Version=4.2.0.0, Colture=neutral, PublicKeyToken=b77a5c561934e089’ and 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 
at Microsoft.Data.Entity.Design.CodeGeneration.CustomGenerator.ProcessTemplate() 
at Microsoft.Data.Entity.Design.CodeGeneration.CustomGenerator.Generate(DbModel model, String codeNamespace, String contextClassName, String connectionStringName) 
at Microsoft.Data.Entity.Design.CodeGeneration.CodeFirstModelGenerator.d__3.MoveNext() 

는 ======== 여기 내 web.config 파일 당신이 프로젝트에 참조로 엔티티 프레임 워크의 V.6와 V.4 모두 추가 보인다

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=301879 
    --> 
<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> 
     ....... 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5.2" /> 
    <httpRuntime targetFramework="4.5.2" /> 
    </system.web> 
    <system.webServer> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <remove name="OPTIONSVerbHandler" /> 
     <remove name="TRACEVerbHandler" /> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> 
     <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
     </dependentAssembly> 
     <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> 
    <system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
    </system.codedom> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <connectionStrings> 
    <add name="myDB" connectionString="data source=local DB;initial catalog=test;user id=user;password=pwd;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
</configuration> 
+0

소식이 있습니까? 나는 정확히 똑같은 문제를 가지고있다 ... – Marc

답변

0

입니다. 그 중 하나를 제거하십시오.

+0

네, 저의 첫 생각입니다. 그러나 나는 어떤 V4 dll도 찾을 수 없다. 또한 모든 NuGet 패키지를 삭제하고 패키지를 다시 설치하면 가끔 문제가 해결됩니다 (대부분의 시간은 아닙니다). – user3616544

+0

연결 문자열과 app.config/web.config에서 어떤 버전이 참조됩니까? – DevilSuichiro

관련 문제