I have a problem creating a new headquarters = building.
Pressing the save button in the create view gives me the following error:
Entities in 'Entities.RRHH_SEDE' participate in the 'FK_RRHH_MUNICIPIO' relationship. 0 related 'RRHH_MUNICIPIO' were found 1 'RRHH_MUNICIPIO' is expected
My driver is as follows:
public ActionResult Create()
{
return View();
}
// POST: RRHH_SEDE/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(mod.RRHH_SEDEModel collection)
{
try
{
// TODO: Add update logic here
ent.RRHH_SEDE entidad = Mapper.Map<mod.RRHH_SEDEModel, ent.RRHH_SEDE>(collection);
db.Modificar(entidad);
return RedirectToAction("Index");
}
catch
{
return View();
}
}
I have added the municipality fields in the model but it does not let me save.
public class RRHH_SEDEModel
{
public short COD_SEDE { get; set; }
public string NOMBRE { get; set; }
public string UBICACION { get; set; }
public virtual RRHH_MUNICIPIO RRHH_MUNICIPIO { get; set; }
public virtual SEG_ESTADO SEG_ESTADO { get; set; }
}
that's my model