2013-12-20 5 views
7

Ich habe Entity Framework auf 6.0 aktualisiert und jetzt bekomme ich eine Ausnahme, die ich nicht herausfinden kann.Der Provider für den invarianten Namen System.Data.SqlClient ist mehrfach angegeben

Beim Erstellen des Konfigurationsabschnittshandlers für entityFramework ist ein Fehler aufgetreten: Der Anbieter für den invarianten Namen 'System.Data.SqlClient' wurde in der Anwendungskonfiguration mehrfach angegeben. Der invariante Name muss für jeden konfigurierten Provider eindeutig sein. (C: \ inetpub \ wwwroot \ scrape \ Scrape \ web.config Zeile 106)

Der Typinitialisierer für 'System.Data.Entity.Internal.AppConfig' hat eine Ausnahme ausgelöst.

Die web.config hat den Anbieter nicht mehrfach aufgeführt und ich habe nur eine web.config für das gesamte Projekt. Ich bin dankbar für jede Hilfe.

Stack Trace

bei System.Data.Entity.Internal.AppConfig.get_DefaultInstance()

bei System.Data.Entity.Internal.LazyInternalConnection..ctor (String nameOrConnectionString)

bei System.Data.Entity.DbContext..ctor (String nameOrConnectionString)

bei Scrape.Data.Contexts.ScabsContext .. ctor() in c: \ inetpub \ wwwroot \ scrape \ Scrape.Data \ Contexts \ ScabsContext.cs: Zeile 17

bei Scrape.Data.Repositories.ScabStore..ctor() in c: \ inetpub \ wwwroot \ scrape \ Scrape.Data \ Repositories \ ScabStore.cs: Zeile 15

bei Scrape.Api.Controllers.ScabsController.get_store() in c: \ inetpub \ wwwroot \ scrape \ Scrape \ Controller \ ScabsController.cs: Zeile 28

bei Scrape.Api.Controllers.ScabsController.Post (Schorf Schorf) in C: \ inetpub \ wwwroot \ schaben \ Scrape \ Controllers ScabsController.cs \: Leitung 52

bei lambda_method (Closure, Object, Objekt [])

bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor. <> c_ DisplayClassc.b _6 (Objektinstanz, Object [] methodParameters)

bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute (Object-Instanz, Object [] Argumente)

bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync (HttpControllerContext Controller, IDictionary`2 Argumente, CancellationToken CancellationToken)

Und mein web.config

<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    </configSections> 
    <connectionStrings> 
    <add name="ScabContext" providerName="System.Data.SqlClient" connectionString="Data Source=bfleming-dev;Initial Catalog=scabs;User ID=scabs_dbo;Password=password" /> 
    <add name="lmsReadWrite" connectionString="Initial Catalog=caV2;Data Source=devsqlnow1.ca-schools.org;Network Library=dbmssocn;User Id=webuser;Password=hyqxYVTH9bjW;MultipleActiveResultSets=True;Application Name=connexus_main;" /> 
    <add name="lmsReadOnly" connectionString="Initial Catalog=caV2;Data Source=devsqlnow1.ca-schools.org;Network Library=dbmssocn;User Id=webuser;Password=hyqxYVTH9bjW;MultipleActiveResultSets=True;Application Name=connexus_main;" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="webpages:Version" value="3.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <authentication mode="None" /> 
    <pages> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Optimization" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     </namespaces> 
    </pages> 
    <profile defaultProvider="DefaultProfileProvider"> 
     <providers> 
     <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" /> 
     </providers> 
    </profile> 
    <membership defaultProvider="DefaultMembershipProvider"> 
     <providers> 
     <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> 
     </providers> 
    </membership> 
    <roleManager defaultProvider="DefaultRoleProvider"> 
     <providers> 
     <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" /> 
     </providers> 
    </roleManager> 
    <!-- 
      If you are deploying to a cloud environment that has multiple web server instances, 
      you should change session state mode from "InProc" to "Custom". In addition, 
      change the connection string named "DefaultConnection" to connect to an instance 
      of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. 
     --> 
    <sessionState mode="InProc" customProvider="DefaultSessionProvider"> 
     <providers> 
     <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /> 
     </providers> 
    </sessionState> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <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="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> 
     </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.1.0.0" newVersion="5.1.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <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> 
</configuration> 

Antwort

19

Das Problem ist der configuration/entityFramework/providers Abschnitt hat einen doppelten Anbieter für die Invariante in der Ausnahme angegeben.

<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 

Auch wenn Sie nur eine bestimmte, was wahrscheinlich passiert ist, dass es eine in einer CONFIG-Datei in einem übergeordneten Verzeichnis angegeben ist. Da .config-Dateien die Konfiguration von den Eltern erben, sehen sie, dass sie doppelt definiert sind.

Sie können diesen Anbieter wahrscheinlich sicher für diese Anwendung entfernen.

Basierend auf CodePlex project wurde dies in 6.1.0-alpha1 durch das Ignorieren von exakten Duplikaten "behoben".

0

Ich erhielt diesen Fehler, weil die Datei "EntityFramework.SqlServer.dll" nicht in der Veröffentlichung für dieses Projekt enthalten war. Das Hinzufügen dieser DLL zum Web-Server-Bin-Ordner behob das Problem.

0

Um dies zu beheben, wickelte ich den übergeordneten Ordner web.config entityFramework Abschnitt mit:

<location path="." inheritInChildApplications="false">

<entityFramework>

...

<entityFramework>

</location>

Siehe https://stackoverflow.com/a/6199749/2718874

Verwandte Themen