steavy
steavy

Reputation: 1576

Changing connection string in app.config for Entity Framework

I am using Entity Framework. In app.config there is stored connection string that EF generates for my database.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="votemeEntities" connectionString="metadata=res://*/VoteModel.csdl|res://*/VoteModel.ssdl|res://*/VoteModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;database=voteme&quot;"
      providerName="System.Data.EntityClient" />
    <add name="VoteMe.Properties.Settings.votemeConnectionString"
      connectionString="server=localhost;User Id=root;database=voteme"
      providerName="MySql.Data.MySqlClient" />
  </connectionStrings>
</configuration>

I need to set Charset in this connection string. How do I do it so my EF use this connection string without any problems? Thanks

Upvotes: 1

Views: 5896

Answers (1)

Oded
Oded

Reputation: 498904

You can add the property at the end of the EF connection string, just before the &quot;.

...abase=voteme;charset=UTF8;&quot;"
    providerName="System.Data.EntityClient" />

Just make sure that the value is properly XML escaped (if needed), otherwise you will break the config file.

Upvotes: 1

Related Questions