locked
Format of the initialization string does not conform to specification starting at index 0 RRS feed

  • Question

  • User1292384883 posted

    I have a Web MVC app talking to a MySQL server. The application uses the Identity Model that is auto-generated by Visual Studio (2013 express). And it also uses my dbContext connection string.    My dbContext is working fine when exchanging data with MySQL.   However, while using the identity model, when I try to register a user.   I get the error: "Format of the initialization string does not conform to specification starting at index 0."  It fails at the following code:

     var result = await UserManager.CreateAsync(user, model.Password);

    Would like to know if anyone knows what the solution is for this.

    Tuesday, September 23, 2014 12:52 AM

Answers

All replies

  • User1292384883 posted

    There seems to be a bug in Visual Studio as far as collation is concerned when dealing with MySQL.

    With my web.config pointing to MySQL server, the default identity context tries to create the aspnet db  with a MS SQL format perhaps requiring two bytes while MySQL uses utf8 which is one byte.

    1- Using code first, if there is not a connectionstring in web.config,  you'll get this error "Format of the initialization string does not conform to specification starting at index 0".

    2- If you add a connection string to web.config for aspnet  then you get this error when registering a user:  "Specified key was too long; max key length is 767 bytes", but it will still create the aspnet db.  In order to get past this, you have to change the collation for aspnet in MySQL to utf16.  Then you can register users at will.

    2- If you change the MySQL server collation to utf16 so you won't have this error at the beginning, then you get this error when registering a user:  Variable 'character_set_client' can't be set to the value of 'utf16'

    It looks like no matter what you do, you are stuck, and the only alternative is to change collation for aspnet to utf16 after it has been created.

    Tuesday, September 23, 2014 3:56 PM
  • User-1818759697 posted

    Hi,

    I get the error: "Format of the initialization string does not conform to specification starting at index 0."  It fails at the following code:

    For this situation, it seems that there is something wrong with your connection string. So, you should make sure that the connection string to your sql server:

    The server/instance name syntax used in the server option is the same for all SQL Server connection strings.

    Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
    Password=myPassword;

    And for more information, you could refer to:

    http://stackoverflow.com/questions/8243008/format-of-the-initialization-string-does-not-conform-to-specification-starting-a

    http://blog.jongallant.com/search?q=solution+to+the+format+of+the+initialization+string+does+not+conform+to+specification+starting+at+index+0+exception#.VCJ6PHkcSM8

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 24, 2014 4:08 AM