简体   繁体   中英

Entity Framework 5 Table Relationship

I use database first. In the auto-generated EF5 code:

Account has ClientID(FK)
Client has AddressID(FK)
Address has public List<EFClient> Clients { get; set; } (i did not specify this in DB but ef5 auto generated it)

When I serialize Address object, it throws exception "there is a circular reference" because the client collection in the address also cotains same address again

What can I do in this situation? How can I not let EF5 auto-generate that Clients collection?

Thanks in advance!

I don't think you actually want to stop EF from auto-generating this navigation property, as it will affect lots of places. What you can do is simply remove the property that it generated from the model, which will remove the property from the class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM