locked
Condition member with a condition other than 'IsNull=False' RRS feed

  • General discussion

  • As many others have encountered previously, I'm running into the issue of not being allowed to have an EF Entity subtype use a conditional on a foreign key property in the parent. The accepted "solution" to this seems to be simply to remove the foreign key property from the parent. From my perspective, this solution is simply unacceptable as I want my model to both reflect the structure in the database AND be extended to make more specialized objects.

    The rational behind not allowing conditionals on a property of the parent class is that you can modify the property and thus make the data inconsistent. I think that the responsibility should be on the developer to make sure their data doesn't become inconsistent. The EF imposing this severely limiting restriction for the purpose of babysitting the developer is totally unnecessary.

    If anything, the EF could automatically override FK properties with conditionals in the subtype, and in this override throw a Runtime exception if the code ever tries to write to it. This makes a heck of a lot more sense to me.

    Thoughts?

    Thursday, October 27, 2011 5:54 PM

All replies

  • Thinking about this some more, it would make even more sense to simply require that the setter is private for the foreign key property that this error refers to. That way there is still zero chance of the data/object becoming corrupt/invalid, yet you aren't sacrificing the integrity of your model.
    Thursday, October 27, 2011 6:47 PM