asa asa - 17 days ago 7
SQL Question

How update string field with length of 300 with entity

I want to update one field of one table, the problem is when it goes to be bigger than 128 character SQL isn't let me to update.


The identifier that starts with … is too long. Maximum length is 128


The strange thing is I was adding 300 character with entity , but I can't update it.

Here is my code:

var objcompany = _entities.Companies.FirstOrDefault(o => o.Username == user.Trim());
objcompany.T="iii4ca4238a0b923820dcnyeytkekhwertgn56nj67fsjk7eukuyc557654junbi76in67iomoor7m6ri6oi68g4yvmo8709a6f75djyksddu849bSarzindfgdgfdAmita3h65utyjein7gfjy6ybhuh6huhuun676grth6jksc0wjzbc32wbc8w3fiofdj8eufghdjn79yjetyjtey";

_entities.SaveChanges();

Answer

Based On your Code.Update your model before saving to Database

_entities.Entry(objcompany).State = EntityState.Modified;//Add this Line 
_entities.SaveChanges();