Invalid connection string

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
dankolle
Posts: 5
Joined: Sat 06 Sep 2014 19:37

Invalid connection string

Post by 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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Invalid connection string

Post by 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);
        }
}

Post Reply