/// <summary> /// Gets the existing alternate key defined on a set of properties, or creates a new one if one is not /// already defined. /// </summary> /// <param name="entityType"> The entity type to get or create the alternate key on. </param> /// <param name="properties"> The properties that are used as the alternate key. </param> /// <returns> The existing or newly created alternate key. </returns> public static IMutableKey GetOrAddKey( [NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyList <IMutableProperty> properties) { Check.NotNull(entityType, nameof(entityType)); return(entityType.FindKey(properties) ?? entityType.AddKey(properties)); }
/// <summary> /// Gets the primary or alternate key that is defined on the given property. Returns null if no key is defined /// for the given property. /// </summary> /// <param name="entityType"> The entity type to find the key on. </param> /// <param name="property"> The property that the key is defined on. </param> /// <returns> The key, or null if none is defined. </returns> public static IMutableKey FindKey([NotNull] this IMutableEntityType entityType, [NotNull] IProperty property) { Check.NotNull(entityType, nameof(entityType)); return(entityType.FindKey(new[] { property })); }
public static IMutableKey?FindKey([NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyProperty property) => entityType.FindKey(new[] { property });