Invalid connection string

Invalid connection string

Postby dankolle » Sat 06 Sep 2014 19:42

I start with the following code:

Code: Select all
         var builder = new MySqlConnectionStringBuilder();

         builder.Host = "----------";
         builder.Port = -----;
         builder.UserId = "--------";
         builder.Password = "------------";
         builder.Direct = true;
         builder.Database = "-------";
         builder.MaxPoolSize = 10;
         builder.ConnectionTimeout = 10;

         var conn2 = new Model.Entities(builder.ConnectionString);


When the code is executed I get the error "key is not supported 'user id'". I compared the string to the one Entity Developer shows me and they are basically the same.

I also tried this syntax: https://www.connectionstrings.com/mysql/

Am I using the wrong classes here?

Daniel
dankolle
 
Posts: 5
Joined: Sat 06 Sep 2014 19:37

Re: Invalid connection string

Postby Shalex » Mon 08 Sep 2014 13:56

Looks like your Model.Entities(argument) constructor expects to receive EntityConnection object instead of the ADO.NET connection string. Try the code like this:
Code: Select all
    class Program
    {
        private static Entities _Entities;
        private static MetadataWorkspace _Workspace = new MetadataWorkspace(
            new[] { "res://*/DataModel1.csdl", "res://*/DataModel1.ssdl", "res://*/DataModel1.msl" },
            new[] { typeof(Entities).Assembly }
            );
        static void Main(string[] args)
        {
            var builder = new MySqlConnectionStringBuilder();

            builder.Host = "----------";
            builder.Port = -----;
            builder.UserId = "--------";
            builder.Password = "------------";
            builder.Direct = true;
            builder.Database = "-------";
            builder.MaxPoolSize = 10;
            builder.ConnectionTimeout = 10;

            EntityConnection entityConnection = new EntityConnection(_Workspace, new MySqlConnection(builder.ConnectionString);
            _Entities = new Entities(entityConnection);
        }

}
Shalex
Devart Team
 
Posts: 7475
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL