I
I
Ilya2015-08-16 19:41:25
ASP.NET
Ilya, 2015-08-16 19:41:25

The entity in the EntityFramework pulls up the wrong data, how to understand?

I will explain with a picture)
a7a09d0099bc4c30983d6a511ced2c61.jpg
There is an entity Wine, which has a parent entity WineRegion. In this example, WineRegionId = 35. But when we expand the parent entity WineRegion, as shown in the following picture,
4311342a01b443d8bb3b6b60dfc0cccf.jpg
Its ID is 6.
Remarkably, there is also a parent entity, WineCountry, whose value, WineCountryId, for this entity, is also 6.
Why are not pulled those data.
This project is written in ASP.NET MVC, EntityFramework is used as ORM

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2015-08-16
@yarosroman

WineRegionId and WineRegion primary key are not related. and WineRegion is a child entity
. How is the model created? code-first, db-first? show the source of the entities

I
Ilya, 2015-08-16
@ilyamikhailov

screenshot, database schema
Child and parent entities.
fe949db3b2f74888a82bbed679c84085.jpg

T
Tsiren Naimanov, 2015-09-20
@ImmortalCAT

metanit.com/sharp/entityframework/index.php
search and read learn
:)
google lazy vs eager loading

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question