Okan Aslankan
Okan Aslankan

Reputation: 3116

C# Entity Framework Migrations adding weird characters to string

I have strings in my MsSql database with nvarchar column type. My seed method sample is this:

protected override void Seed(Sro.Models.ApplicationDbContext db)
    {
        Konu iyimi = new Konu { isim ="ıyımıdır", lastAktifTime = DateTime.Now, konuUrl = "iyimi", };
        db.Konu.AddOrUpdate(iyimi);
    }

when I execute the seed method some characters "ç, ö" are okay but "ı" character saving as "ý" in database, for example "ıyımıdır" appears "ýyýmýdýr". I tried differen sql servers but the result is same. By the way there's no problem with website queries. When I try to add new row when debugging it is okay. It doesn't make any sense to me. Thanks for any help.

Upvotes: 1

Views: 3939

Answers (2)

Szynkie
Szynkie

Reputation: 79

Try add 'N' before string eg: UPDATE TableName SET Name = N'śćżas' WHERE Id = 0

Upvotes: 0

umut özkan
umut özkan

Reputation: 132

Add "Charset=utf8" to entity connection string.

Entity Framework C# Insert Data russian encoding problems

Upvotes: 1

Related Questions