I'm trying to create a mapping between the 2 tables using EF Core Data Annotation.
So here's my sample scenario. Let's suppose I have theses classes that consist of following properties
Orders
[Key]
public int OrderId {get;set}
public string OrderNumber {get;set;}
OrderStatuses
[Key]
public int OrderStatusId {get;set}
public string OrderNumber {get;set;}
public StatusEnum Status {get;set} // Pending, Delivered, Cancel
I have this example data:
OrderId OrderNumber // Order Table
1 11111
2 11111
3 11111
4 22222
OrderStatusId OrderNumber Status
1 11111 Pending
2 22222 Pending
Basically, I created OrderStatuses
table that stores the status of the OrderNumber
but they have no relationship since I have no idea how to make them Many-to-One
using Data Annotation of Entity Framework Core without using the key
. I want to achieve this so I can use the .Include
method in fetching all the info.
The key is, Many Orders but One Status only. I hope somebody helps me.