public ForeignKey(Microsoft.EntityFrameworkCore.Metadata.IForeignKey foreignKey, EntityType entityType) { DeclaringEntityType = entityType.Model.FindEntityType(foreignKey.DeclaringEntityType.Name); Properties = foreignKey.Properties.Select(p => DeclaringEntityType.FindProperty(p.Name)).ToList(); PrincipalEntityType = entityType.Model.FindEntityType(foreignKey.PrincipalEntityType.Name); PrincipalKey = new Key(foreignKey.PrincipalKey, PrincipalEntityType); }