public int Save(PersonaModel model) { if (model.PersonaId == 0) { model.PersonaId = _db.Persona.Consecutivo(x => x.PersonaId); _db.Persona.Add(model.PersonaFactory()); } else { _db.Entry(model.PersonaFactory()).State = EntityState.Modified; } _db.SaveChanges(); return(model.PersonaId); }