aspnet/EntityFramework — pull request #600 by ajcvickers (2014-08-29 17:37:34+00:00)
Title: EDMLib v4?

EDMLib v4? (Metadata robustness and non-primary keys)

(This change looks big, but the only really substantive changes are in EntityType.cs)

This change adds non-primary keys as a first-class part of the model as per issue #537. In looking at this it became clear that it was time to add some more robustness to the core metadata to help prevent the model getting into inconsistent state--for example, removing keys that are being referenced by foreign keys. Most of this change is about adding that robustness. Specifically:
- Be explicit and consistent about being able to either find and existing metadata item or create a new one if it doesn't yet exist. This matches the way we tend to use metadata, especially from fluent APIs and conventions. It helps protect against a couple of bugs we have had recently where duplicate items (properties or keys) were added by mistake. The methods are currently called GetOrAddXxx, but we can discuss other ideas.
- Error checking for things like CLR properties actually existing
- Checks to prevent removal of items that are currently still being referenced in the model