Entity Framework Core 2.1 failing to translate query properly

前端 未结 1 1472
萌比男神i
萌比男神i 2021-01-22 06:01

I have an existing database which I am accessing from 2 separate projects, one an ASP.NET MVC 5 project, and one running .NET Core 2.1 using the respective Entity Framework veri

1条回答
  •  臣服心动
    2021-01-22 06:55

    You need to add the foreign key explicitly to the WorkOrder class as it does not match the EFCore convention:

    public class WorkOrder
    {
        [Key]
        public int WorkOrderId { get; set; }
    
        public int Job_JobID {get;set;} 
    
        [ForeignKey("Job_JobID")]
        public virtual Job Job { get; set; }
    
    }
    

    0 讨论(0)
提交回复
热议问题