Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having a problem getting my head wrapped around EF6.

I have the following tables:

AspNetUsers (entity provided by MVC)
ICSProfile
ICSEvent
ICSVehicle
ICSEventClass
ICSEventEntry

I want to associate them as follows:

0) A given AspNetUser can have one ICSProfile record. A given profile can have one or more ICSVehicle records.

1) A given ICSProfile can have one or more ICSEvents. An event can have one or more ICSEventClasses.

(this is where I'm a bit dodgy)

2) A given ICSProfile can enter one or more vehicles in an ICSEvent one or more times, but each entry for a given vehicle has to be in a different ICSEventClass within the ICSEvent.


So, let's say our vehicle owner's name is John, and he has a 2012 Mustang, and a 1967 Mustang. Let's also say that user Bob has created an event that has three classes:

2005-2014 Mustang
1965-1973 Mustang
Street Machine, All

John wants to enter his 2012 Mustang in the 2005-2014 Mustang class, as well as the Street Machine All class, and finally he wants to enter his other car into the 1965-73 Mustang class.

What I have tried:

So far, my entity diagram looks like this:

AspNetUser(1)<--->(1)ICSProfile(1)<--->(*)ICSVehicle(1)<--------------------------\
                   |                                                              |
                   |                                                              |
                   |                                                              |
                  (*)ICSEvent(1)<-->(*)ICSEventClass(*)<-->(*)ICSEventEntry(*)<---/


Is that right? Does it look weird? It looks like a big circle (and circles are usually bad when you're writing code).

If I didn't explain this well enough, let me know, and I'll modify the question.
Posted
Updated 16-Oct-17 8:20am
v3
Comments
Richard Deeming 17-Oct-17 13:22pm    
Shouldn't that be: ICSEventClass(1)<-->(*)ICSEventEntry

Presumably each entry is only for a single class.

Unless you need to store extra details with the entry, it's effectively a many-to-many relationship between ICSVehicle and ICSEventClass.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900