3 Replies - 519 Views - Last Post: 05 June 2020 - 02:06 PM Rate Topic: -----

#1 BassemK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 06-March 19

Entity builder metadata illegal characters in path.

Posted 04 June 2020 - 02:00 PM

i use this function to build MySQL Entity Connection :


public static EntityConnection buildEntityConnection()
        {
            // Specify the provider name, server and database.
            string providerName = "MySql.Data.MySqlClient";

            // Initialize the connection string builder for the
            // underlying provider.
            MySqlConnectionStringBuilder MySQLBuilder =  new MySqlConnectionStringBuilder();
            
            // Set the properties for the data source.
            MySQLBuilder.Server = myconn.server;
            MySQLBuilder.Database = myconn.database;
            MySQLBuilder.Port = Convert.ToUInt32( myconn.port);
            MySQLBuilder.UserID = myconn.uid;
            MySQLBuilder.Password = myconn.password;
            MySQLBuilder.IntegratedSecurity = true;
            MySQLBuilder.ConvertZeroDateTime = true;
            MySQLBuilder.ConnectionTimeout = 1600000;

            // Build the SqlConnection connection string.
            string providerString = MySQLBuilder.ToString();

            // Initialize the EntityConnectionStringBuilder.
            EntityConnectionStringBuilder entityBuilder =  new EntityConnectionStringBuilder();

            //Set the provider name.
            entityBuilder.Provider = providerName;

            // Set the provider-specific connection string.
            entityBuilder.ProviderConnectionString = providerString;

            // Set the Metadata location.
            
            entityBuilder.Metadata = "metadata=res://*/MrSModels.MrSalesModel.csdl|res://*/MrSModels.MrSalesModel.ssdl|res://*/MrSModels.MrSalesModel.msl";


            EntityConnection conn = new EntityConnection(entityBuilder.ToString());
            return conn;
        }



the error :

System.Data.Entity.Core.MetadataException: 'At least one of the input paths is not valid because either it is too long or it has incorrect format.'


Is This A Good Question/Topic? 0
  • +

Replies To: Entity builder metadata illegal characters in path.

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7462
  • View blog
  • Posts: 25,113
  • Joined: 05-May 12

Re: Entity builder metadata illegal characters in path.

Posted 04 June 2020 - 02:18 PM

Did you check the inputs to your builders to make sure that you are not passing any illegal characters? We can't really help you much from out end since we can't see any of the values you are passing to your builders except for those few constants that you shared.
Was This Post Helpful? 0
  • +
  • -

#3 BassemK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 06-March 19

Re: Entity builder metadata illegal characters in path.

Posted 04 June 2020 - 04:16 PM

yes i checked it , the issue with this line
            entityBuilder.Metadata = "metadata=res://*/MrSModels.MrSalesModel.csdl|res://*/MrSModels.MrSalesModel.ssdl|res://*/MrSModels.MrSalesModel.msl";

This post has been edited by Skydiver: 05 June 2020 - 02:04 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7462
  • View blog
  • Posts: 25,113
  • Joined: 05-May 12

Re: Entity builder metadata illegal characters in path.

Posted 05 June 2020 - 02:06 PM

I don't use Entity Framework, but based on what I know about the various SQL connection string builders, I don't need to pass in the keyname and the equal sign. In your case: "metadata=" is very likely not needed.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1