1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

and that is the question =) I have tried to add this property in different places and with different formatings. But there is an error. So how do I set this property correctly?
@steavy - Why didn't you say what you tried in your question (useful information, you know)? And what error are you getting? Exactly?
nevermind. Resolved. Your answer helped. Thanks) I knew that I need to put this property there but didn`t know about correct formating.
@steavy - Yeah, the format is a bit too wrapped. It belongs in the XML encoded portion after "provider connection string=" within the XML encoded quotes...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.