locked
Entity Framework not connecting to online mysql server but working fine in local server RRS feed

  • Question

  • User1601010121 posted

    My web site working fine if i'm connected to local mysql server but when i'm using online connection it shows Error

    Format of the initialization string does not conform to specification starting at index 115.

    I search net regarding this issue and come up connection string problem . i checked my mysql connection it was successful in test but and i regenerated Entity Connection string for online server problem is same here is my Web.

    <?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=169433
    -->
    <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>
    
    <system.web>
    <authentication mode="Forms">
    <forms defaultUrl="EminentHome.aspx" loginUrl="eminent.aspx" slidingExpiration="true" timeout="20"></forms>
    </authentication>
    <authorization>
    <allow roles="admin" />
    <deny users="?" />
    </authorization>
    <compilation debug="true" targetFramework="4.5">
    <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <add assembly="MySql.Data.Entity, Version=6.9.8.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D" />
    </assemblies>
    <buildProviders>
    <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
    </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <pages>
    <controls>
    <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
    </controls>
    </pages>
    <customErrors mode="Off"/>
    </system.web>
    <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    </appSettings>
    
    <entityFramework>
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
    <providers>
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    </entityFramework>
    <connectionStrings>
    <!--<add name="Conn" connectionString="server=127.0.0.1;database=lami;uid=root;pwd=; Pooling=false;Character Set=utf8; Convert Zero Datetime=True " />-->
    <!--<add name="lamiEntities1" connectionString="metadata=res://*/App_Code.AS.csdl|res://*/App_Code.AS.ssdl|res://*/App_Code.AS.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;database=lami&quot;" providerName="System.Data.EntityClient" />-->
    <add name="Conn" connectionString="server=mysql.myserver.com;user id=myid;pwd=mypass;database=mydb; Pooling=false;Character Set=utf8; Convert Zero Datetime=True " />
    <add name="lamiEntities1" connectionString="metadata=res://*/App_Code.AS.csdl|res://*/App_Code.AS.ssdl|res://*/App_Code.AS.msl;provider=MySql.Data.MySqlClient;connectionstring=&quot;server=mysql.mysever.com;uid=myid;pwd=mypass@;database=mydb;" providerName="System.Data.EntityClient" />
    
    </connectionStrings>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.5.0" newVersion="5.2.5.0" />
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>
    




    ado.net working fine but entity Modal is giving error . 

    Friday, January 22, 2016 12:41 PM

Answers

  • User-986267747 posted

    Hi morfious90,

    Format of the initialization string does not conform to specification starting at index 115.

    checked my mysql connection it was successful in test but and i regenerated Entity Connection string for online server problem is same here is my Web.

    According to your error message, it seems the problem is caused by the connection string, Are you trying to create a new ADO.NET Entity model via visual studio and automatically generate Entity Connection string for online server? please check if the connection is right and it could connect the mysql database on remote server.

    http://stackoverflow.com/questions/21206184/cant-use-a-mysql-connection-for-entity-framework-6

    <add name="Conn" connectionString="server=mysql.myserver.com;user id=myid;pwd=mypass;database=mydb; Pooling=false;Character Set=utf8; Convert Zero Datetime=True " />

    <add name="lamiEntities1" connectionString="metadata=res://*/App_Code.AS.csdl|res://*/App_Code.AS.ssdl|res://*/App_Code.AS.msl;provider=MySql.Data.MySqlClient;connectionstring=&quot;server=mysql.mysever.com;uid=myid;pwd=mypass@;database=mydb;" providerName="System.Data.EntityClient" />

    In my experience, the Entity Connection string be automatically generated Entity Connection should be like the following string, there are some space between the strings. Besides, i suggest that you'd better directly connect the mysql database in your visual studio  and check if you could connect it.

    <add name="lamiEntities1" connectionString="metadata=res://*/App_Code.AS.csdl|res://*/App_Code.AS.ssdl|res://*/App_Code.AS.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=mysql.mysever.com;user id=root;database=lami&quot;" providerName="System.Data.EntityClient" />

    Best Regards,

    Klein zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 25, 2016 4:50 AM