简体   繁体   中英

c# Entity Framework navigation problem

i've a doubt on navigation property in EF4 Model designer.

Let's suppose we have two Entities: Hotel - Country.

If I design an 1:1 association between them, the designer add two navigation properties for each entity. One of them is in the Hotel (named Country), the second one is in the Country (named Hotel).

Now, if i reason on it, i can say that the Hotel navigation property in the Country entity is unuseful. Can i delete it? Why does Entity Framework designer add it?

I'd say Hotel-Country should be a many-to-one relationship, no? Country can have many Hotels.

However, to answer the question: yes, you can simply delete navigation properties (you can also turn it off when creating the association in the designer). The designer adds it 'by default'.

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