简体   繁体   中英

How to prevent EF6 to merge entities when using database first?

I have three tables: user, specialUser and special

User contains all the base fields. specialUser has an id which is both, the FK (to user table) and PK and has another field specialId, which is a FK to the special table.

Now, when I add the tables to the edmx, EF has merged the specialuser with the user entity! User now has an extra navigation property to special. I don't want this. I want to have a separate entity for specialuser.

How can I force EF 6 not to merge these entities?

I had that issue in the past, the only way I got the result I wanted is adding an extra column to the table, like EF_FIX bit nullable to the table.

add something like this to specialUser and it should do, i think, what you want

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