problem with discriminator columns

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
mindplay
Posts: 148
Joined: Tue 13 Dec 2011 22:58
Location: Ithaca, NY

Post by mindplay » Tue 06 Mar 2012 16:13

Shalex wrote:We consider that setting discriminator-value (null, not null, etc) implicitly is incorrect behaviour. This value should be specified by a user explicitly basing on the approach he is going to implement.
But the user has specified what approach he is going to implement - it's a choice you make when you specify the relation.

The ability to specify a discriminator-value for an abstract class isn't even useful in the first place - an abstract class doesn't need a discriminator, because you can't make an instance of an abstract class.

If you want to validate the model for correctness, the correct validation to perform would be to verify that an abstract class does not specify a useless discriminator-value, and issue an error-message if it does.

The fact that NH requires you to explicitly specify a discriminator-value as "not null" is just circumstance - it requires you to be explicit about the fact that an abstract class itself does not have a discriminator.

But In ED, the user has already indicated what type of inheritance pattern they intend to use - making the user actually type the words "not null" into the discriminator-input doesn't make any sense, because it's the only configuration that actually makes any sense.

Add to that the fact that many users won't know or understand how, why or when they need to type those words into that input - a few SO or Google searches will reveal that this is a commonly asked question, and a poorly documented issue.

From a number of forum threads and blog-posts, you will see that most users never even learn the correct way to configure this - they simply end up adding "dummy" discriminator-values to all of their abstract classes, not understanding why, or how to avoid doing so...

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 12 Mar 2012 16:39

The default behaviour is changed: Discriminator Value is set to Not Null for base abstract classes by default now. We will post here when the corresponding build of Entity Developer is available for download.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 16 Mar 2012 17:56

New version of Entity Developer 4.3 is released!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=23647 .

Post Reply