Entity Framework 5.0b2 Code First: One-To-Many and One-To-One for the same table, WITH Cascade Delete

喜欢而已 提交于 2019-11-30 21:51:35
G.Y

I listed other options to describe your abstraction:

A.

How about using 3 tables like that:

user 1-* paymentSource
user 1-0..1 DefaultPaymentSource
DefaultPaymentSource 0..1-1 PaymentSource

or this:

B.

user 1-* paymentSource
user 1-0..1 DefaultPaymentSource
DefaultPaymentSource --derive from--> PaymentSource

or this:

C.

user 1-* paymentSource
PaymentSource has addtional boolean field for "IsDefault"

I vote for choice B as best one.

I am certain that having two relations comming from the same source table to the same destination table is not going to be a good idea.. it is probably breaking some rule or pattern regarding databases best practice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!