Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011
    Posts
    11

    Question mysql, EF6 and app.config file ?

    After some trials and errors i was able to enable migration successfully but update-database failed with another error:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    I tested the connection and all is fine as i can access to mysql using 'Tools/Connect Database' with the same connection strings.

    Forcing the migration by issuing update-database -ConnectionStringName "my connection" failed with another error:
    No connection string named 'MMODatabase' could be found in the application config file.
    Using the same command but passing -ConnectionString result that error:

    The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file, or could not be loaded.
    What should contains that config file ?

    Thanks for your helps guys

  2. #2
    Join Date
    Dec 2009
    Location
    Atlantis
    Posts
    167
    Hmmm things I would check, Is your MYSql definitely running? check services in your task manager and look to see if MYSql56 is running. Can you post your connection string, there maybe a typo in it.

    it should look like this.

    Code:
    <connectionStrings>
        <add name="MMODatabase" connectionString="Server=localhost;Database=MyMMODatabase;Uid=root;Pwd=TEST;Allow User Variables=True" providerName="MySql.Data.MySqlClient" />
    </connectionStrings>

  3. #3
    Join Date
    Mar 2004
    Location
    Anacortes, WA
    Posts
    4,168
    Quote Originally Posted by SachaM View Post
    After some trials and errors i was able to enable migration successfully but update-database failed with another error:



    I tested the connection and all is fine as i can access to mysql using 'Tools/Connect Database' with the same connection strings.

    Forcing the migration by issuing update-database -ConnectionStringName "my connection" failed with another error:


    Using the same command but passing -ConnectionString result that error:



    What should contains that config file ?

    Thanks for your helps guys
    It almost looks as if it's trying to connect to MSSQL and not MySQL. Also, this has to be done in the web.config file of the web project - not the app.config of the data project.

    Here is my connection string element:
    Code:
    <add name="MMODatabase" connectionString="Server=localhost;Database=dev_buzzmmo_2;Uid=root;Pwd=nelson;Allow User Variables=True" providerName="MySql.Data.MySqlClient" />
    Here is my system.data element:
    Code:
    	<system.data>
    		<DbProviderFactories>
    			<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="MySQL Database Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
    		</DbProviderFactories>
    	</system.data>
    And here is my entityFramework element:
    Code:
    	<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    		<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    		<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>
    Does that look like yours?
    Need any help? Feel free to PM me - or send an email directly to nelson@3dbuzz.com!

  4. #4
    Join Date
    Oct 2011
    Posts
    11
    I spotted a difference in my defaultConnectionFactory that was hooked to LocalDbConnectionFactory, but changing that to MySql like yours didn't changed anything at the end.

    I put my web and app config files there in case you spotted something that should or should not be there in case of silent failed instal.
    Web.config
    App.config for mmodata

    and yes the connection to mysql machine works fine... It would have been too easy otherwise...

    Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •