Search code examples
oracle-databaseentity-framework-corecyrillic

EF Core Oracle NVARCHAR2 - Can't save cyrillic to db


When trying to keep the Cyrillic alphabet in the database, only inverted question marks are saved in the database.

The model looks like this

public class Roles {
    public string Name { get; set; }
    public string Appname { get; set; }
    public string Description { get; set; }
}

Creating a context like this

modelBuilder.Entity<Roles>(entity =>
{
                entity.HasKey(e => new { e.Name, e.Appname });

                entity.ToTable("ROLES");

                entity.HasIndex(e => new { e.Name, e.Appname })
                    .HasName("PK_ROLES")
                    .IsUnique();

                entity.Property(e => e.Name)
                    .HasColumnName("NAME")
                    .HasMaxLength(100)
                    .IsUnicode(false);

                entity.Property(e => e.Appname)
                    .HasColumnName("APPNAME")
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Description)
                    .HasColumnName("DESCRIPTION")
                    //.HasMaxLength(256)
                    //.IsUnicode(true);
                    .HasColumnType("NVARCHAR2(256)");
});

Tried and what is commented out and the next line

The table looks created correctly

And the execution of this code

using (var context = new FrontContext())
{
    var roles = context.Roles.ToList();
    var role = new Roles{ 
               Name        = $"ADMINS{DateTime.Now.ToString("HHmmss")}", 
               Appname     = "TESTAPP", 
               Description = "тестовая роль"};
    context.Add(role);
    context.SaveChanges();
}

...gives such a picture


Solution

  • Check thread:4291600@Oracle, they fixed it.

    Just update Oracle.EntityFrameworkCore to 2.19.80 then you are good to go.