Reputation: 179
I am having problem using the Entity Framework 4 with MySQL connector 6.3.6. I have made MySQL dabase to utf8 - default collation to use the unicode on my website. The problem is that I can read the unicode to my website from the database by when I try to save the unicode string using entity framework 4 it put question marks on my database. I even set up the Unicode property from the Visual Studio designer but to no avail. Am I missing something or is there something you have to do to make entity framework write unicode to the database?
Upvotes: 3
Views: 2574
Reputation: 1491
In my case, somehow unicode configuration was disabled in context, here the solution is to set true value for .IsUnicode(true) Instead of .IsUnicode(false)
modelBuilder.Entity<Center>()
.Property(e => e.CenterCode)
.IsUnicode(true);
Let's enjoy this trick.
Upvotes: 1
Reputation: 61
create connectionstring with 'charset=utf8' it on Web.config file
<connectionStrings>
<add name="con" connectionString="server=localhost;Uid=root;password=;database=webpro;charset=utf8 " />
</connectionStrings>
Upvotes: 2
Reputation: 179
Ok after alot of research it turns out that the MySQL connector 6.3.6 got a connection string parameter 'charset=utf8'. you need to add this to your connection string.
Upvotes: 4