1

我有一個MVC4應用程序準備好部署。該應用程序是數據庫第一個實體框架與MySQL而不是MSSQL。至於dubugging,我沒有與下面的連接字符串的錯誤,但是當我去部署應用程序到Amazon Elastic Beanstalk它將我帶到登錄屏幕,但是當我去登錄時,它會引發一個錯誤:部署 - 實體框架工作的MySQL

Failed to find or load the registered .Net Framework Data Provider. 

我不知道什麼是正確的方式來爲MySQL部署配置web.config,假設web配置是開始的問題。關於我失蹤的任何想法?

的Web.Config:

 <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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
</configSections> 
<connectionStrings> 
<add name="MyFinDevEntities" connectionString="metadata=res://*/MyFinAdminModel.csdl|res://*/MyFinAdminModel.ssdl|res://*/MyFinAdminModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;user id=xxxxx;password=xxxxx;server=xxxxx.us-west-2.rds.amazonaws.com;database=xxxxDev&quot;" providerName="System.Data.EntityClient" /> <!-- providerName="MySql.Data.MySqlClient"--> 
</connectionStrings> 

<appSettings> 
<add key="webpages:Version" value="2.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> 
<httpRuntime targetFramework="4.5" /> 
<compilation debug="true" targetFramework="4.5" /> 
<customErrors mode="Off"></customErrors> 
<authentication mode="Forms"> 
    <forms loginUrl="~/Account/Login" timeout="2880" /> 
</authentication> 
<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> 
<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-ISAPI-4.0_32bit" /> 
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 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.Helpers" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
    </dependentAssembly> 
</assemblyBinding> 
</runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    </entityFramework> 
</configuration> 
+0

是連接器/ Net安裝在目標服務器上? – bricelam

+0

@Brice我正在部署到Amazon的Elastic Beanstalk EC2服務器,因此我將不得不在EC2實例上安裝此連接器?我如何去做這件事?感謝您的輸入 – TMan

+0

我對亞馬遜技術不太熟悉,但基本上有兩種選擇。 1)將MySql.Data.dll(和MySql.Data.Entities.dll)的副本部署到bin目錄(稱爲bin-deployloying),或2)下載並安裝[Connector/Net](http:// dev .mysql.com/downloads/connector/net /)在執行代碼的服務器上。 – bricelam

回答

3

如果您在濱部署/ xcopying MySQL的連接器/網絡提供商,可能需要以下片段添加到您的web.config

<system.data> 
    <DbProviderFactories> 
    <add name="MySQL Data Provider" 
     invariant="MySql.Data.MySqlClient" 
     description="Data Provider for MySQL" 
     type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" /> 
    </DbProviderFactories> 
</system.data>