Entity framework returning incorrect data from columns with same name

陌路散爱 提交于 2019-12-08 02:04:12

问题


I have a few tables in my database which are mapped to an edmx. Using the entity framework to return data from these tables, I've encountered a problem where the value in the "name" column from one of my higher level data models is being populated into each model below it.

I'm pulling the data like this:

var query = (from a in context.things
             where a.id == 1
             select a);

var model = query.Select(a => new modelA()
{
    Name = a.name,
    Bs = a.Bs.Select(b => new modelB()
    {
        Name = b.name,
        Cs = b.Cs.Select(c => new modelC()
        {
            Name = c.name,
            Ds = c.Ds.Select(d => new modelD()
            {
                Name = d.name
            })
        })
    })
}).FirstOrDefault();

b.name, c.name and d.name are all returning the same value as a.name despite my database definitely having different values in across these tables.

Could this be a caching issue?


Update

After upgrading the mySql connector to the latest version (6.7.4.0) I am still encountering the error.

After the upgrade it seems i can get 3 levels deep before the data in the name column starts reappearing :(

来源:https://stackoverflow.com/questions/19007589/entity-framework-returning-incorrect-data-from-columns-with-same-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!