c# - Entity Framework - include multiple collection-properties in 2nd level navigation property throws EntityCommandExecutionException -
i'm using mysql 6.9.9 in combination ef 6. know if want include multiple navigation-properties add include, works fine.
for example (works):
return _repositorymanager.getrepository<kundenrepository>().getsingle(x => x.id == kundeid, x => x.kundensachbearbeiter, x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.kontakteaddressen), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.abteilungliste), x => x.zuordnungen.select(dest => dest.kontakteaddressen.laender));
now have situation want include collection zuordnungen -> kontakteaddressen (works):
return _repositorymanager.getrepository<kundenrepository>().getsingle(x => x.id == kundeid, x => x.kundensachbearbeiter, x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.kontakteaddressen), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.abteilungliste), x => x.zuordnungen.select(dest => dest.kontakteaddressen.laender), x => x.zuordnungen.select(dest => dest.kontakteaddressen).select(dest => dest.kontaktebemerkungen));
and if want include collection zuordnungen -> kontakteaddressen crashes:
return _repositorymanager.getrepository<kundenrepository>().getsingle(x => x.id == kundeid, x => x.kundensachbearbeiter, x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.kontakteaddressen), x => x.kundensachbearbeiter.select(dest => dest.mitarbeiter).select(dest => dest.abteilungliste), x => x.zuordnungen.select(dest => dest.kontakteaddressen.laender), x => x.zuordnungen.select(dest => dest.kontakteaddressen).select(dest => dest.kontaktebemerkungen), x => x.zuordnungen.select(dest => dest.kontakteaddressen).select(dest => dest.kontaktekommunikation));
additional information:
this getsingle method (i'm using repository pattern):
public virtual tdto getsingle(expression<func<tentity, bool>> where, params expression<func<tentity, object>>[] navigationproperties) { tdto result; using (var context = new entities(_connectionstringname)) { iqueryable<tentity> query = context.set<tentity>(); query = navigationproperties.aggregate(query, (current, navigationproperty) => current.include(navigationproperty)); var item = query.asnotracking().where(where).singleordefault(); // exception happens here result = _mapper.map<tdto>(item); } return result; }
my entitymodel: entitymodel
my datamodel: datamodel
i system.data.entity.core.entitycommandexecutionexception
innerexception: {"unknown column 'extent6.id' in 'on clause'"}
details:
system.data.entity.core.entitycommandexecutionexception ist aufgetreten. hresult=-2146232004 message=an error occurred while executing command definition. see inner exception details. source=entityframework stacktrace: @ system.data.entity.core.entityclient.internal.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior) @ system.data.entity.core.objects.internal.objectqueryexecutionplan.execute[tresulttype](objectcontext context, objectparametercollection parametervalues) @ system.data.entity.core.objects.objectquery
1.<>c__displayclass7.<getresults>b__6() @ system.data.entity.core.objects.objectcontext.executeintransaction[t](func
1 func, idbexecutionstrategy executionstrategy, boolean startlocaltransaction, boolean releaseconnectiononsuccess) @ system.data.entity.core.objects.objectquery1.<>c__displayclass7.<getresults>b__5() @ system.data.entity.infrastructure.defaultexecutionstrategy.execute[tresult](func
1 operation) @ system.data.entity.core.objects.objectquery1.getresults(nullable
1 formergeoption) @ system.data.entity.core.objects.objectquery1.<system.collections.generic.ienumerable<t>.getenumerator>b__0() @ system.data.entity.internal.lazyenumerator
1.movenext() @ system.linq.enumerable.singleordefault[tsource](ienumerable1 source) @ system.data.entity.core.objects.elinq.objectqueryprovider.<getelementfunction>b__2[tresult](ienumerable
1 sequence) @ system.data.entity.core.objects.elinq.objectqueryprovider.executesingle[tresult](ienumerable1 query, expression queryroot) @ system.data.entity.core.objects.elinq.objectqueryprovider.system.linq.iqueryprovider.execute[tresult](expression expression) @ system.data.entity.internal.linq.dbqueryprovider.execute[tresult](expression expression) @ system.linq.queryable.singleordefault[tsource](iqueryable
1 source) @ sur.runtime.data.entityframework.dataaccess.genericdatarepository2.getsingle(expression
1 where, expression1[] navigationproperties) in c:\users\daniel\source\repos\surframework.git\sur.runtime.data\entityframework\dataaccess\genericrepository.cs:line 84 innerexception: code=0 errorcode=-2147467259 hresult=-2147467259 message=unknown column 'extent6.id' in 'on clause' number=1054 source=mysql.data stacktrace: @ mysql.data.mysqlclient.mysqlstream.readpacket() @ mysql.data.mysqlclient.nativedriver.getresult(int32& affectedrow, int64& insertedid) @ mysql.data.mysqlclient.driver.getresult(int32 statementid, int32& affectedrows, int64& insertedid) @ mysql.data.mysqlclient.driver.nextresult(int32 statementid, boolean force) @ mysql.data.mysqlclient.mysqldatareader.nextresult() @ mysql.data.mysqlclient.mysqlcommand.executereader(commandbehavior behavior) @ mysql.data.entity.efmysqlcommand.executedbdatareader(commandbehavior behavior) @ system.data.common.dbcommand.executereader(commandbehavior behavior) @ system.data.entity.infrastructure.interception.dbcommanddispatcher.<reader>b__c(dbcommand t, dbcommandinterceptioncontext
1 c) @ system.data.entity.infrastructure.interception.internaldispatcher1.dispatch[ttarget,tinterceptioncontext,tresult](ttarget target, func
3 operation, tinterceptioncontext interceptioncontext, action3 executing, action
3 executed) @ system.data.entity.infrastructure.interception.dbcommanddispatcher.reader(dbcommand command, dbcommandinterceptioncontext interceptioncontext) @ system.data.entity.internal.interceptabledbcommand.executedbdatareader(commandbehavior behavior) @ system.data.common.dbcommand.executereader(commandbehavior behavior) @ system.data.entity.core.entityclient.internal.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior) innerexception:
edit
i created same scenario on mssql database (also changed provider in app.config) , it's working perfectly, guess it's maybe bug in mysql provider?
Comments
Post a Comment