0

I've got problem in repository pattern while saving. this is what I wrote in unit of work:

public void Save()
        {
            db.SaveChanges();
        }'

db is for my UserList table

when I write user name and try to change the password, the error shows this: System.Data.Entity.Validation.DbEntityValidationException

here is my code for changing the password:

using (UnitOfWork db = new UnitOfWork())
        {
            var q = db.UList.Get();
            if(q != null)
            {
                UserList U = new UserList()
                {
                    Password = NewPassText.Text
                };
                db.UList.Update(U);
                db.Save();
                this.Hide();
                ProFrm ProFrm = new ProFrm(); ProFrm.Show();
            }
            else
            {

            }
  • Well, probably something in the new password it's not in line with what your database accepts. You can see here https://stackoverflow.com/questions/21606454/how-to-handle-system-data-entity-validation-dbentityvalidationexception so you can find what is wrong. – spyros__ Apr 17 '22 at 11:58
  • Does this answer your question? [How to handle System.Data.Entity.Validation.DbEntityValidationException?](https://stackoverflow.com/questions/21606454/how-to-handle-system-data-entity-validation-dbentityvalidationexception) – Jiale Xue - MSFT Apr 18 '22 at 01:44

0 Answers0