2016-05-12 95 views
0

我的应用程序在Visual Studio中编写时出现问题。在Visual Studio中构建是可以的,但是当我尝试在Mono上运行时。服务器显示无法找到请求的.Net Framework数据提供程序。 PostgreSQL和Mono

System.ArgumentException 
Unable to find the requested .Net Framework Data Provider. It may not be installed. 

enter image description here

我使用的EntityFramework 6和dotConnect为PosgreSQL。

这里是我的web.config:

<?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=301880 
    --> 
<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="PostgreEntitiesConnectionString" connectionString="metadata=res://*/Models.Entities.DataModel1.csdl|res://*/Models.Entities.DataModel1.ssdl|res://*/Models.Entities.DataModel1.msl;provider=Devart.Data.PostgreSql;provider connection string=&quot;User Id=postgres;Host=192.168.50.89;Database=postgres;Initial Schema=public&quot;" providerName="System.Data.EntityClient" />--> 
     <add name="EntityManager" connectionString="User Id=postgres;Password=****;Host=127.0.0.1;Database=postgres; Charset=utf8; Persist Security Info=True;Initial Schema=public" providerName="Devart.Data.PostgreSql" /></connectionStrings> 
    <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" /> 
     <httpRuntime targetFramework="4.6" /> 
     <customErrors mode="Off" /> 
     <httpModules> 
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
     </httpModules> 
    </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="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 
      </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
    <system.webServer> 
     <validation validateIntegratedModeConfiguration="false" /> 
     <modules> 
      <remove name="ApplicationInsightsWebTracking" /> 
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 
     </modules> 
    </system.webServer> 
    <entityFramework> 
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
      <parameters> 
       <parameter value="mssqllocaldb" /> 
      </parameters> 
     </defaultConnectionFactory> 
     <providers> 
      <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity.EF6, Version=7.5.644.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> 
     </providers> 
    </entityFramework> 
    <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> 
    <system.data> 
     <DbProviderFactories> 
      <!--<add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version= 7.5.639.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />--> 
     </DbProviderFactories> 
    </system.data> 
</configuration> 

回答

0

解决方案是在system.data-> DbProviderFactories部分取消注释

<!--<add name="dotConnect for PostgreSQL" invariant="De 

。修正版本Devart.Data.PostgreSql的当前版本(我的是7.5.639.0),并加入这一行

<remove invariant="Devart.Data.PostgreSql"></remove> 

<add name="dotConnect for PostgreSQL" inv.... 

在system.data-> DbProviderFactories部分之前。

最终的Web.config:

<?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=301880 
    --> 
<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="PostgreEntitiesConnectionString" connectionString="metadata=res://*/Models.Entities.DataModel1.csdl|res://*/Models.Entities.DataModel1.ssdl|res://*/Models.Entities.DataModel1.msl;provider=Devart.Data.PostgreSql;provider connection string=&quot;User Id=postgres;Host=192.168.50.89;Database=postgres;Initial Schema=public&quot;" providerName="System.Data.EntityClient" />--> 
     <add name="EntityManager" connectionString="User Id=postgres;Password=*****;Host=127.0.0.1;Database=postgres; Charset=utf8; Persist Security Info=True;Initial Schema=public" providerName="Devart.Data.PostgreSql" /></connectionStrings> 
    <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" /> 
    <httpRuntime targetFramework="4.6" /> 
    <customErrors mode="Off" /> 
    <httpModules> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
    </httpModules> 
    </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="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules> 
     <remove name="ApplicationInsightsWebTracking" /> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 
    </modules> 
    </system.webServer> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity.EF6, Version=7.5.644.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> 
    </providers> 
    </entityFramework> 
    <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> 

<system.data> 
    <DbProviderFactories> 
     <remove invariant="Devart.Data.PostgreSql"></remove> 
     <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version= 7.5.644.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> 
    </DbProviderFactories> 
    </system.data></configuration> 
相关问题