Unicode Entity Framework

I have a table with an nvarchar field (MS SQL Server 2008 R2). For testing, this code works fine:

Update [Screenshots] set name=N'' where id=230246 

Right now I created an Entity Framework model, I installed Unicode as True

enter image description here

then I'm trying to update my record:

  public void Put(FormDataCollection formData) { string filename = formData.Get("filename"); var screenshot = c.Screenshots.Where(p => p.filename == filename).FirstOrDefault(); if (screenshot != null) { screenshot.name = formData.Get("description"); c.SaveChanges(); } } 

but I got "?????" instead of unicode value. How to do it? I know the AsNonUnicode method, but this method only works for LINQ.

+5
unicode entity-framework
source share
1 answer
  • Are you sure that formData.Get("description") returns a UTF-8 string (that it doesn’t convert somewhere)?

  • What is your approach to entity structure? Code First / Design First / Database First?
    Try to delete the database and recreate it - delete the database, and then right-click on the designer -> Generate database from model...

  • Get the Entity Framework Profiler from the Nu-get package manager and see which request sends to the database.

+3
source share

All Articles