I have a simple model in which I have a base class A and a subclass (discriminated) B. The B configuration specifies a not-null many-to-one relationship.
This result in a single table A which contains a NOT-NULL foreign-key for the many-to-one relationship. Since that many-to-one only exists for subclass B, I get a constraint violation when I try to save instances of class A (no many-to-one relationship specified). I don't want to make the relationship nullable and I don't want to use joined-subclass. I am using Sql Server and it would be great if somehow I could add a Check Constraint expression that will ensure that if the disctriminator is 'B', the foreign key relationship is not null.
Is this possible or is there some other way to achieve this.
thanks,
craig
|