MySQL keyword is not supported: port error in C # application

I am trying to connect to a MySQL database in my C # .Net application

I get this error when trying to connect: Keyword not supported: "port".

An error message appears with my connection string

<add name="mydataEntities" connectionString="server=myserver.com;port=3306;password=xxxx;user id=yyyy;database= mydatabase;persistsecurityinfo=True" providerName="MySql.Data.MySqlClient" /> 

I have a link for: MySql.Data 6.9.7.0 (ADO.Net driver for MySQL) And MySql.Data.Entity.EF6 6.9.7.0 (Entity Framework 6.0 support supported)

In my configuration, I have:

  <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Culture=neutral, PublicKeyToken=c5687fc88969c44d"> </provider> </providers> </entityFramework> <dependentAssembly> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.9.7.0" newVersion="6.9.7.0" /> </dependentAssembly> <system.data> <DbProviderFactories> <remove invariant="MySql.Data.MySqlClient" /> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data> 
Connection string

installed here:

 public class Repository { protected mydataEntities DbContext; public Repository() { DbContext = new mydataEntities (ConfigurationManager.ConnectionStrings["mydataEntities"].ConnectionString); } } 

I noticed that the stack trace seems to be using the System.Data.SqlClient provider, as shown below:

I removed the MySql.Data and MySql.Data.Entity.EF6 links, cleared the solution, added backlinks, then rebuilt .....

Can someone help me figure out the source of this error?

Why MySQL connector is not used using the provider name: MySql.Data.MySqlClient, as indicated in my configuration.

  at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString) at System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(String nameOrConnectionString) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName() at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 
+5
source share
1 answer

Here is the solution:

I removed the following code from a partial class that overrides the connection string n of the database.

 public partial class mydataEntities { public mydataEntities(string connectionString) : base(connectionString) { } } 

I was still confused about the solution, but it looks like with this code the connection was trying to use the Mssql data provider instead of MySql

0
source

All Articles