I have a problem that when I am trying to insert a Japanese word to my database. It insert them, but when I check the word, it looks like this: "??????"
So I explored in stackoverflow and tried many solution but failed and I still have same problem. Here is my code if someone can help:
Here is the word I enter into a text box:
ケンガンアシュラ
Database shows it as:
????????????
Model:
[Display(Name = "Alternative Name")]
[StringLength(200)]
public string Alternative_Name { get; set; }
At SQL Server it has a datatype of
nvarchar(200)
Here is my view:
<div class="form-group">
<h4>@Html.LabelFor(model => model.Alternative_Name, new { @class = "control-label col-md-3" })</h4>
<div class="col-md-6">
@Html.EditorFor(model => model.Alternative_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Alternative_Name, "", new { @class = "text-danger" })
</div>
</div>
I tried to update it using migration and changed Unicode to true:
AlterColumn("dbo.Post", "Alternative_Name", c => c.String(maxLength: 200, unicode: true));
But nothing works, the database keeps showing it as ?????
.
UPDATE: In my case the solution simply in the model builder or model class which explain the relation btw tables and attributes the Unicode was set to false so I changed it to true and solved:
modelBuilder.Entity<Post>()
.Property(e => e.Alternative_Name)
.IsUnicode(true);