SapientGuardian / SapientGuardian.EntityFrameworkCore.MySql

MySQL database provider for Entity Framework Core
52 stars 9 forks source link

Problem with UTF 8 in insert / update #35

Closed tobiashoeft closed 7 years ago

tobiashoeft commented 7 years ago

Hey folks ,

i have a problem with the "insert and update" maybe in my WebApi.

if i debug all works fine with german "äääöööüü etc.." on controller and models from angular 2 service. The values shown the ÖÄ.

But if the Create or Update runs to db the values GroÊin Table.

If i change the values in Database and call a HttpGet the Values shown ÄÖÖ on Ui.

My backend is 14.04 ubuntu with mysql 5.7.18 asp.net core 1.1.0 "SapientGuardian.EntityFrameworkCore.MySql": "7.1.14",

My Dependencies. { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", "type": "platform" }, "Microsoft.AspNetCore.Mvc": "1.1.0", "Microsoft.AspNetCore.Routing": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.Extensions.Logging.Debug": "1.1.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", "System.Security.Cryptography.Algorithms": "4.3.0", "MimeKit": "1.10.0", "MailKit": "1.10.0", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0", "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0", "jose-jwt": "2.0.2", "Microsoft.ApplicationInsights.AspNetCore": "1.0.2", "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0", "Syncfusion.EJ.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.EJ.Pivot": "14.4600.0.15-preview2-final", "Syncfusion.Compression.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.Pdf.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.OfficeChart.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.Presentation.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.DocIO.AspNet.Core": "14.4600.0.15-preview2-final", "Giffel.ServiceLibary": "1.0.0-*", "Serilog": "2.3.0", "SapientGuardian.EntityFrameworkCore.MySql": "7.1.14", "Microsoft.AspNetCore.SignalR.Server": "0.2.0-*", "Microsoft.AspNetCore.WebSockets": "1.0.0" },

@SapientGuardian

SapientGuardian commented 7 years ago

I'm not able to reproduce this problem. I wrote a very simple test app:

     var c = serviceProvider.GetService<TestContext>();
            c.Clients.Add(new Client() { SomeString = "äääöööüü etc.." });            
            c.SaveChanges();

And can see the correct characters in the database. image

tobiashoeft commented 7 years ago

Hey @SapientGuardian ,

ok sounds like theres another problem in my web api? But if i debug and transport the model from Angular 2 service "post" to Webapi i see in debug the ääööö.

let headers = new Headers({ 'Authorization': 'Bearer ' + currentUser.auth_token ,'Content-Type': 'application/json; charset=utf-8;'});

SapientGuardian commented 7 years ago

I didn't quite follow that. If you just hard-code some test data instead of taking it from the json, does it write the correct values?

tobiashoeft commented 7 years ago

Okay maybe there's another problem in my Pipeline from Web App to Web Api i'll post it.

So actually there's no problem with your MySQL database provider ;)!

Thanks for your fast replies

tobiashoeft commented 7 years ago

Okay maybe reopen it.

I've wrote an sample app to check when i insert äääööö with the MySQLCommand why to database , and it's working. But with the provider it doesnt work.

here is my sample app propably it will help you to understand?

I dont know why it doesnt work with ääööö on the Provider why :( ConsoleApp1.zip

SapientGuardian commented 7 years ago

This is what I get when I run your sample:

image

tobiashoeft commented 7 years ago

so strange! i get : Microsoft .NET Core Shared Framework Host Version : 1.1.0 Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86 And if i send the data to mysql i will get :

unbenanntes bild

Any idea whats going on on my build machine? :(

SapientGuardian commented 7 years ago

Nothing comes to mind. What do you get if you use the official mysql provider?

tobiashoeft commented 7 years ago

Theres is actually no support for .net core 1.1.0 i get an error if i use it :( The Problem is tracked :(

Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory..ctor(Microsoft.EntityFrameworkCore.Infrastructure.ISensitiveDataLogger`1<Microsoft.EntityFrameworkCo

SapientGuardian commented 7 years ago

What if you downgrade your sample app to 1.0.1, just to test?

tobiashoeft commented 7 years ago

still same Problem :(

my new project json. `{ "version": "1.0.1", "buildOptions": { "emitEntryPoint": true },

"dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.1" }, "SapientGuardian.EntityFrameworkCore.MySql": "7.1.14" },

"frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } } }`

SapientGuardian commented 7 years ago

I meant with the official provider.

tobiashoeft commented 7 years ago

I've created a new Table in Database .

Create 1.0 App with official MySqlProvider.

Still cant write ÄÄÄLLLÄÖÖÖÖ to MySql but Read 'ÄÄÄLÖÖÖÖ it works fine.

:(

SapientGuardian commented 7 years ago

Ok, well unless both code-bases have the same bug, that pretty much rules out this provider, the underlying SapientGuardian mysql ado.net connector, the official provider, and the official ado.net connector. I doubt EF itself could be messing this up, but you could try taking this up with them. I think the most likely suspect at this point is your database itself having some odd configuration. I'm not sure what else to tell you at this point, sorry.

tobiashoeft commented 7 years ago

The point is when i call the using (MySqlCommand command = new MySqlCommand) It will pass the ääälöööääö to database.

Thats crappy , its works in past a couple of weeks :(!

I dont know why it doesnt work now!

I update my solution and build machine to 1.1.0 and at this point the official provider dont work than i use yours.

At this point the UTF8 encoding dont work :( !

So the point is that the Get / read still work when i wrote manually ööää in the MySql Tables.

What a creepy problem :(

But thanks for your replies and help

tobiashoeft commented 7 years ago

My Problem is the SSL.

When i disable SSL in WEBAPI it works. :( !

So i must enable / add the ssl zertifikat to MYSQL db?

or what will i need to do @SapientGuardian maybe you can help me last time :-)

SapientGuardian commented 7 years ago

I'm not sure how the two would be related - EF and MySQL have no idea whether or not your API is being accessed over SSL. Besides, your sample console app isn't a web api at all.

tobiashoeft commented 7 years ago

Yeah thats right! But i cant explain it why !locally now its work Win10 but on my Linux machine Server it doesnt work. I cant reproduce it.

I only clean my refrenches i activate Http and back to Https the values stores right in format :( !

Thats CRAAZY!