How can I add properties to an association (relationship) using the Entity Framework
I am using Entity Framework 4. I have a many-to-many association (relationship) between two entities:
- Account
- Subscription
The relationship is therefore: AccountSubscription. So an account (over time) can have many subscriptions and, obviously, a particular Subscription type can be held by many Accounts at once.
I want to add properties to this relationship (e.g. StartDate, EndDate, PaymentStatus). I can't see a way in Entity to add properties to an Association table. What is the best开发者_如何学C way to represent this using Entity?
You cannot add properties to associations in EF. You must simply create a new Entity instead of an Association, in order to mimic an association with properties.
So you would have
Accounts (Entity) - [0..1 to Many] - AccountSubscription (Entity) - [Many to 0..1] - Subscription (Entity)
精彩评论