Problem is Table Columns are getting updated with NULL if i dont defined them in my controller.Below is my Controller Action.
[HttpPost]
public ActionResult GetEditRecord(UserDetail MU, string actiontype)
{
if (actiontype == "Save")
{
UserDetail Ud = new UserDetail();
_unitOfWork = new GenericUnitOfWork();
Ud.ID = MU.ID;
Ud.FirstName = MU.FirstName;
Ud.LastName = MU.LastName;
Ud.IsDeleted = false;
Ud.FkCompanyId = 5;
Ud.FkRegionId = 1;
_unitOfWork.GetRepoInstance<UserDetail>().update(Ud);
_unitOfWork.SaveChanges();
}
return RedirectToAction("ManageUsers"); ;
}
I Have 10 columns in UserDetails but i need to edit only 6 columns but when i click on update the other fields are getting save as NULL. Below is My GeneralRepository code to update Entity
public void update(TEntity entity)
{
_dbContext.Entry(entity).State = EntityState.Modified;
}
Please tell if i am missing something.