I have a table in my SQL Server database with a column
ReviewText of datatype
If I insert or update rows via a SQL query with
N'' prefix, for example:
UPDATE [dbo].[Reviews] SET ReviewText = N'It's OK. ðŸ˜Š' WHERE Id = [id]
it works great and it will write smiley ðŸ˜Š into the table.
But if I insert it from code:
var review = _context.UserReview.FirstOrDefault(x => x.Id == [id]); review.ReviewText = "It's OK. ðŸ˜Š";
the code will store
It's OK. ?? without smiley into the column.
How to fix this in code?
I fixed this issue. The problem was in entity model mapping. I have changed
entity.Property(e => e.ReviewText).HasColumnType("text");
entity.Property(e => e.ReviewText).HasColumnType("nvarchar(max)");
Thanks to all!