I came across the EF6 Code First context with several DbSet POCOs that have navigation properties (and foreign keys) between them, for example:
public partial class Person { public Guid Id { get; set; } public virtual ICollection<Address> Address { get; set; } } public partial class Address { public Guid Id { get; set; } public Guid FK_PersonId { get; set; } public virtual Person Person { get; set; } } modelBuilder.Entity<Person>() .HasMany (e => e.Address) .WithRequired (e => e.Person) .HasForeignKey (e => e.FK_PersonId) .WillCascadeOnDelete(false);
Given these types, is there any proper way (i.e., not to iterate over the POCO properties / fields by reflection and guessing) to programmatically determine that Address has FK_PersonId pointing to the Id Person property?
c # entity-framework foreign-keys ef-code-first poco
vzwick
source share