public void EditTest() { Device v = new Device(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.ID = "44tvMxOP9"; v.ProductId = AddProduct(); context.Set <Device>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(DeviceVM)); DeviceVM vm = rv.Model as DeviceVM; v = new Device(); v.ID = vm.Entity.ID; vm.Entity = v; vm.FC = new Dictionary <string, object>(); vm.FC.Add("Entity.ID", ""); vm.FC.Add("Entity.ProductId", ""); _controller.Edit(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <Device>().FirstOrDefault(); } }