I have a table in my SQL Server database with a column ReviewText
of datatype NVARCHAR(MAX)
.
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?
ReviewText
declared as unicode to ef? Do you check the saved value in the database or debugger?