I am trying to create my model in the Entity Framework and I am trying to use it using the first version of the code.
I currently have 3 tables in my database. My status table has all the statuses used in the web application. I have a news table. And I have a news status table. The reason I did this is because I donβt want all the statuses to be available for news articles, just a couple of them. So my 3 tables will look like this:
News table:
NewsId int required primary key Title varchar required Body varchar required NewsStatusId int required foreign key
NewStatus table:
NewsStatusId int required primary key StatusId int required foreign key
Status table
StatusId int required primary key Name varchar required
When creating classes for this, do I need to create classes for News, Status and NewsStatus? I only thought about the news and status? What would my relationship between classes 2/3 look like?
My News class is as follows
public class News { public int NewsId { get; set; }
Status Class:
public class Status { public int StatusId { get; set; } public string Name { get; set; } }
What would these classes look like with the relationships between classes 2/3?
Any code samples will be appreciated.
Brendan vogt
source share