innerException: { >message: "An error has occurred.", >exceptionMessage: "Invalid column name 'Route_rte_pk'. Invalid column name 'Route_rte_pk'.", > >The error refers to "Route_rte_pk", but the controller that is causing the problem is RunSheetHeaders which should not have any column referring to "Route" or "rte_pk". > >I have searched through the entire solution and not found this string anywhere. Any ideas where I should look? > ><b>< update ></b> > >I have looked into SQL Server Profiler and found that the sql being generated by Entity Framework is this: > >SELECT > 1 AS [C1], > [Extent1].[rnh_pk] AS [rnh_pk], > [Extent1].[rnh_date] AS [rnh_date], > [Extent1].[rnh_rtefk] AS [rnh_rtefk], > [Extent1].[Route_rte_pk] AS [Route_rte_pk] > FROM [dbo].[RunSheetHeader] AS [Extent1] > >Route is a separate table which is joined to this table by the rnh_rtefk = Route.rte_pk > >So I guess something is wrong in my model? > >Here's my model definition code: > ><pre> [Table("RunSheetHeader")] > public partial class RunSheetHeader > { > public RunSheetHeader() > { > RunSheetDetails = new HashSet<RunSheetDetail>(); > } > > [Key] > public Guid rnh_pk { get; set; } > > [Column(TypeName = "date")] > public DateTime rnh_date { get; set; } > > public Guid rnh_rtefk { get; set; } > > public virtual Route Route { get; set; } > > public virtual ICollection<RunSheetDetail> RunSheetDetails { get; set; } > }>