0
Views doesn’t have a primary key so it causes me to make a mistake:
Error: The number of Primary key values passed must match number of Primary key values defined on the Entity.
How could I avoid this mistake?
public ActionResult AtualizaCliente(int id)
{
sistema_mobileEntities dao = new sistema_mobileEntities();
return View(dao.vcliente.Find(id));
}
You have this PK set in your model ? Because what the error ta saying is that you don’t have the PK set...
– Érik Thiago
Are you using Entityframework not? Which version?
– Miguel Angelo
@Érikthiago, yes, you’re right about the error message, more in my doubt I talk I’m working with a Views,so I don’t have a primary key.
– Harry
If you don’t have a primary key,
Find
will not work. You can try to get otherwise:return View(dao.vcliente.FirstOrDefault(v => v.Id == id));
– Filipe Oliveira
@itasouza Would the question not be How to map database views in Entityframework?
– Miguel Angelo
In ASP.NET MVC the term View is something else entirely different from View in the database.
– Miguel Angelo