-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Labels
area-jsonarea-queryarea-save-changescustomer-reportedpriority-bugIssues which requires API breaks and have bigger impact hence should be fixed earlier in the releaseIssues which requires API breaks and have bigger impact hence should be fixed earlier in the releaserc-2
Milestone
Description
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseCollation("Chinese_PRC_CI_AS");
modelBuilder.Entity<User>(entity =>
{
entity.Property(e => e.UserId).ValueGeneratedNever();
});
modelBuilder.Entity<User>().OwnsOne(u=>u.Address , u =>
{
u.ToJson();
});
}
public partial class User
{
[Key]
public Guid UserId { get; set; }
[StringLength(50)]
public string Name { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string City { get; set; }
public User User { get; set; }
}
When data is added, the Chinese in Json column is escaped.
User user = new User()
{
UserId = Guid.NewGuid(),
Name = "超超",
Address = new Address()
{
City = "上海",
}
};
context.Add(user);
context.SaveChanges();
If you edit this record, the Chinese in the Json column will not be escaped.
var user = context.User.First();
user.Address.City = "北京";
context.SaveChanges();
Whether there is a parameter configuration that allows us to define whether Chinese is escaped.
Include provider and version information
EF Core version:7.02
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0)
Operating system:Windows 11
IDE: Visual Studio 2022 17.5.0 Preview 6.0
KAJOOSH and hexianggui
Metadata
Metadata
Assignees
Labels
area-jsonarea-queryarea-save-changescustomer-reportedpriority-bugIssues which requires API breaks and have bigger impact hence should be fixed earlier in the releaseIssues which requires API breaks and have bigger impact hence should be fixed earlier in the releaserc-2

