所以我是代码新手,我有一个已经完成并且无法更改的数据库,当我在控制器中调用客户端时出现此错误,因为它会查找不存在的 Empresa_id,所以我可以告诉如何查找正确的字段?
return View(clientes.ToPagedList(pageNumber, pageSize));
it return this select
SELECT
[Extent1].[id] AS [id],
[Extent1].[name] AS [name],
[Extent1].[empresa] AS [empresa],
[Extent1].[Empresa_id] AS [Empresa_id]
FROM [dbo].[cliente] AS [Extent1]
ORDER BY [Extent1].[name] ASC}
public class cliente
{
[Key]
public int id { get; set; }
public string name { get; set; }
public int empresa { get; set; } // foreing key
public virtual empresa Empresa { get; set; }
}
public class empresa
{
[Key]
public int id { get; set; }
public string descripcion { get; set; }
public virtual ICollection<cliente> Clientes { get; set; }
}