title: Updating data from view model mvc5 (EF6)
body: <p>I have a problem when I Update the database from model! 
  I have an interface and I identify an Edit Function  and I created a class to implement this function as follow: </p>
  
  <pre><code>public void Edit(byte? id)
  {
         var entity = getByID(id);
         UnitOfWork.DbContext.Entry(entity).State = EntityState.Modified;
         UnitOfWork.Commit();
  }
  </code></pre>
  
  <p>In the controller I called this function as follow: </p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(BackendModuleViewModel model)
  {
         var entity = model.ConvertToEntity(model);
         _backendModuleRepository.Edit(entity.BNM_ID);
          return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>When I run the project it tells me that the primary key is null ! </p>
  
  <p>The function (getByID) in Edit that located in a repository is implemented as follow: </p>
  
  <pre><code>public BackendModule getByID(byte? id) 
  { 
        var entity = DbSet.FirstOrDefault(x =&gt; x.BNM_ID == id); 
        return entity; 
  } 
  </code></pre>