json - Entity Framework problems with SQL Server -
i'm try migrate entity framework 6.0 webapi default localdb sql server 2016. problem is, on localdb works fine after running the database-update on sql server "one many" , "one one" relations don't work anymore , error shown below. if i'm switching of proxy generation
base.configuration.proxycreationenabled = false;
the error not available related data "kunde" in case "null":
[{"id":1,"name":"a","kunde":null},{"id":2,"name":"b","kunde":null}]
i'm using simple model:
public class projekt { public int id { get; set; } public string name { get; set; } public virtual kunde kunde { get; set; } } public class kunde { public int id { get; set; } public bool { get; set; } public string name { get; set; } }
error: {"message":"fehler","exceptionmessage":"fehler des typs \"objectcontent
1\" beim serialisieren des antworttexts für den inhaltstyp \"application/json; charset=utf-8\".","exceptiontype":"system.invalidoperationexception","stacktrace":null,"innerexception":{"message":"fehler","exceptionmessage":"error getting value 'kunde' on 'system.data.entity.dynamicproxies.projekt_335b396fdc5fa9f94df84d1a8d73a70c6c6914cccdacc23329bd6c56450777d9'.","exceptiontype":"newtonsoft.json.jsonserializationexception","stacktrace":" bei newtonsoft.json.serialization.dynamicvalueprovider.getvalue(object target) bei newtonsoft.json.serialization.jsonserializerinternalwriter.calculatepropertyvalues(jsonwriter writer, object value, jsoncontainercontract contract, jsonproperty member, jsonproperty property, jsoncontract& membercontract, object& membervalue) bei newtonsoft.json.serialization.jsonserializerinternalwriter.serializeobject(jsonwriter writer, object value, jsonobjectcontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty) bei newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty) bei newtonsoft.json.serialization.jsonserializerinternalwriter.serializelist(jsonwriter writer, ienumerable values, jsonarraycontract contract, jsonproperty member, jsoncontainercontract collectioncontract, jsonproperty containerproperty) bei newtonsoft.json.serialization.jsonserializerinternalwriter.serializevalue(jsonwriter writer, object value, jsoncontract valuecontract, jsonproperty member, jsoncontainercontract containercontract, jsonproperty containerproperty) bei newtonsoft.json.serialization.jsonserializerinternalwriter.serialize(jsonwriter jsonwriter, object value, type objecttype) bei newtonsoft.json.jsonserializer.serializeinternal(jsonwriter jsonwriter, object value, type objecttype) bei newtonsoft.json.jsonserializer.serialize(jsonwriter jsonwriter, object value) bei system.net.http.formatting.basejsonmediatypeformatter.writetostream(type type, object value, stream writestream, encoding effectiveencoding)
1.<>c__displayclass7.b__6() bei system.data.entity.core.objects.objectcontext.executeintransaction[t](func
bei system.net.http.formatting.jsonmediatypeformatter.writetostream(type type, object value, stream writestream, encoding effectiveencoding)
bei system.net.http.formatting.basejsonmediatypeformatter.writetostream(type type, object value, stream writestream, httpcontent content) bei system.net.http.formatting.basejsonmediatypeformatter.writetostreamasync(type type, object value, stream writestream, httpcontent content, transportcontext transportcontext, cancellationtoken cancellationtoken)\r\n--- ende der stapelüberwachung vom vorhergehenden ort, dem die ausnahme ausgelöst wurde --- bei system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) bei system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) bei system.runtime.compilerservices.taskawaiter.getresult()
bei system.web.http.webhost.httpcontrollerhandler.<writebufferedresponsecontentasync>d__1b.movenext()","innerexception":{"message":"fehler","exceptionmessage":"an error occurred while executing command definition. see inner exception details.","exceptiontype":"system.data.entity.core.entitycommandexecutionexception","stacktrace":" bei system.data.entity.core.entityclient.internal.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior) bei system.data.entity.core.objects.internal.objectqueryexecutionplan.execute[tresulttype](objectcontext context, objectparametercollection parametervalues) bei system.data.entity.core.objects.objectquery1 func, idbexecutionstrategy executionstrategy, boolean startlocaltransaction, boolean releaseconnectiononsuccess) bei system.data.entity.core.objects.objectquery
1.<>c__displayclass7.b__5() bei system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute[tresult](func1 operation) bei system.data.entity.core.objects.objectquery
1.getresults(nullable1 formergeoption) bei system.data.entity.core.objects.objectquery
1.execute(mergeoption mergeoption) bei system.data.entity.core.objects.dataclasses.entityreference1.load(mergeoption mergeoption) bei system.data.entity.core.objects.dataclasses.relatedend.deferredload() bei system.data.entity.core.objects.internal.lazyloadbehavior.loadproperty[titem](titem propertyvalue, string relationshipname, string targetrolename, boolean mustbenull, object wrapperobject) bei system.data.entity.core.objects.internal.lazyloadbehavior.<>c__displayclass7
2.b__2(tproxy proxy, titem item) bei system.data.entity.dynamicproxies.projekt_335b396fdc5fa9f94df84d1a8d73a70c6c6914cccdacc23329bd6c56450777d9.get_kunde() bei getkunde(object ) bei newtonsoft.json.serialization.dynamicvalueprovider.getvalue(object target)","innerexception":{"message":"fehler","exceptionmessage":"diesem command ist bereits ein geöffneter datareader zugeordnet, der zuerst geschlossen werden muss.","exceptiontype":"system.invalidoperationexception","stacktrace":" bei system.data.sqlclient.sqlinternalconnectiontds.validateconnectionforexecute(sqlcommand command) bei system.data.sqlclient.sqlconnection.validateconnectionforexecute(string method, sqlcommand command) bei system.data.sqlclient.sqlcommand.validatecommand(string method, boolean async) bei system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method, taskcompletionsource1 completion, int32 timeout, task& task, boolean asyncwrite) bei system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method) bei system.data.sqlclient.sqlcommand.executereader(commandbehavior behavior, string method) bei system.data.sqlclient.sqlcommand.executedbdatareader(commandbehavior behavior) bei system.data.common.dbcommand.executereader(commandbehavior behavior)
1 c) bei system.data.entity.infrastructure.interception.internaldispatcher
bei system.data.entity.infrastructure.interception.dbcommanddispatcher.<reader>b__c(dbcommand t, dbcommandinterceptioncontext1.dispatch[ttarget,tinterceptioncontext,tresult](ttarget target, func
3 operation, tinterceptioncontext interceptioncontext, action3 executing, action
3 executed) bei system.data.entity.infrastructure.interception.dbcommanddispatcher.reader(dbcommand command, dbcommandinterceptioncontext interceptioncontext) bei system.data.entity.internal.interceptabledbcommand.executedbdatareader(commandbehavior behavior) bei system.data.common.dbcommand.executereader(commandbehavior behavior)
bei system.data.entity.core.entityclient.internal.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior)"}}}}
Comments
Post a Comment