简体   繁体   中英

Entity Framework: No mapping for the Unicode character exists in the target multibyte code page

I have a function which updates a field of table using entity framework. This function retrieves a User record using userid , and updates the UserState field of a user to false.

My function works, but sometimes thrown this exception.

Entity Framework: No mapping for the Unicode character exists in the target multibyte code page.

Does anyone know what might be causing this?

My function:

 using (_DBEntities = new DBEntities())
            {
                var item = (from _key in _DBEntities.Users
                            where _key.UserID==userid
                            select _key).SingleOrDefault();

                    item.UserState=false;
                    _DBEntities.Users.ApplyChanges(item);
                    _DBEntities.SaveChanges();

            }

It's hard to tell exactly what's going on from the current info, but the exception suggests that you're encountering an error with the encoding/decoding of a Unicode character (no valid mapping can be found).

That probably hints at some problematic data within your Users table, if the exception is indeed occurring the within the above code block).

Character Encoding in the .Net Framework: http://msdn.microsoft.com/en-us/library/ms404377.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM