Sunday, 15 April 2012

entity framework - how to seperate aspnet.identity.entityframework to its own assembly -



entity framework - how to seperate aspnet.identity.entityframework to its own assembly -

i trying move appicationdbcontext out of asp.net mvc5 web application project own assembly. have tried creating class library info access layer , using nuget install aspnet.identity assemblies.

i cannot work. have tried few different examples not sure how best way this.

i have created basic illustration in codeplex : https://testdal.codeplex.com/

this empty mvc5 website reference class library dal. in dal models default sample website along references , basic test code seek , register user.

i next error :

instance failure. description: unhandled exception occurred during execution of current web request. please review stack trace more info error , originated in code. exception details: system.invalidoperationexception: instance failure. source error: line 18: line 19: var user = new applicationuser() { username = "paul" }; line 20: var result = usermanager.create(user, "123456"); line 21: line 22: source file: c:\users\paul\documents\visual studio 2013\projects\emptywebsite\dal\register.cs line: 20 stack trace: [invalidoperationexception: instance failure.] system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, uint32 waitformultipleobjectstimeout, boolean allowcreate, boolean onlyonecheckconnection, dbconnectionoptions useroptions, dbconnectioninternal& connection) +414 system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, taskcompletionsource`1 retry, dbconnectionoptions useroptions, dbconnectioninternal& connection) +78 system.data.providerbase.dbconnectionfactory.trygetconnection(dbconnection owningconnection, taskcompletionsource`1 retry, dbconnectionoptions useroptions, dbconnectioninternal oldconnection, dbconnectioninternal& connection) +196 system.data.providerbase.dbconnectioninternal.tryopenconnectioninternal(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource`1 retry, dbconnectionoptions useroptions) +146 system.data.providerbase.dbconnectionclosed.tryopenconnection(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource`1 retry, dbconnectionoptions useroptions) +16 system.data.sqlclient.sqlconnection.tryopeninner(taskcompletionsource`1 retry) +94 system.data.sqlclient.sqlconnection.tryopen(taskcompletionsource`1 retry) +110 system.data.sqlclient.sqlconnection.open() +96 system.data.entity.infrastructure.interception.dbconnectiondispatcher.<open> b__36(dbconnection t, dbconnectioninterceptioncontext c) +36 system.data.entity.infrastructure.interception.internaldispatcher`1.dispatch(ttarget target, action`2 operation, tinterceptioncontext interceptioncontext, action`3 executing, action`3 executed) +138 system.data.entity.infrastructure.interception.dbconnectiondispatcher.open(dbconnection connection, dbinterceptioncontext interceptioncontext) +477 system.data.entity.sqlserver.<>c__displayclass34.<usingconnection> b__32() +344 system.data.entity.sqlserver.<>c__displayclass1.<execute> b__0() +34 system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute(func`1 operation) +251 system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute(action operation) +196 system.data.entity.sqlserver.sqlproviderservices.usingconnection(dbconnection sqlconnection, action`1 act) +420 system.data.entity.sqlserver.sqlproviderservices.usingmasterconnection(dbconnection sqlconnection, action`1 act) +335 system.data.entity.sqlserver.sqlproviderservices.createdatabasefromscript(nullable`1 commandtimeout, dbconnection sqlconnection, string createdatabasescript) +151 system.data.entity.sqlserver.sqlproviderservices.dbcreatedatabase(dbconnection connection, nullable`1 commandtimeout, storeitemcollection storeitemcollection) +287 system.data.entity.core.common.dbproviderservices.createdatabase(dbconnection connection, nullable`1 commandtimeout, storeitemcollection storeitemcollection) +110 system.data.entity.core.objects.objectcontext.createdatabase() +236 system.data.entity.migrations.utilities.databasecreator.create(dbconnection connection) +143 system.data.entity.migrations.dbmigrator.ensuredatabaseexists(action mustsucceedtokeepdatabase) +207 system.data.entity.migrations.infrastructure.migratorbase.ensuredatabaseexists(action mustsucceedtokeepdatabase) +42 system.data.entity.migrations.dbmigrator.update(string targetmigration) +136 system.data.entity.migrations.infrastructure.migratorbase.update() +33 system.data.entity.internal.databasecreator.createdatabase(internalcontext internalcontext, func`3 createmigrator, objectcontext objectcontext) +175 system.data.entity.internal.internalcontext.createdatabase(objectcontext objectcontext, databaseexistencestate existencestate) +150 system.data.entity.database.create(databaseexistencestate existencestate) +444 system.data.entity.createdatabaseifnotexists`1.initializedatabase(tcontext context) +288 system.data.entity.internal.<>c__displayclassf`1.<createinitializationaction> b__e() +165 system.data.entity.internal.internalcontext.performinitializationaction(action action) +110 system.data.entity.internal.internalcontext.performdatabaseinitialization() +660 system.data.entity.internal.lazyinternalcontext.<initializedatabase> b__4(internalcontext c) +31 system.data.entity.internal.retryaction`1.performaction(tinput input) +143 system.data.entity.internal.lazyinternalcontext.initializedatabaseaction(action`1 action) +292 system.data.entity.internal.lazyinternalcontext.initializedatabase() +123 system.data.entity.internal.internalcontext.initialize() +42 system.data.entity.internal.internalcontext.getentitysetandbasetypefortype(type entitytype) +39 system.data.entity.internal.linq.internalset`1.initialize() +137 system.data.entity.internal.linq.internalset`1.include(string path) +41 system.data.entity.infrastructure.dbquery`1.include(string path) +142 system.data.entity.queryableextensions.include(iqueryable`1 source, string path) +205 system.data.entity.queryableextensions.include(iqueryable`1 source, expression`1 path) +305 microsoft.aspnet.identity.entityframework.userstore`6.getuseraggregateasync(expression`1 filter) +610 microsoft.aspnet.identity.entityframework.userstore`6.findbynameasync(string username) +1069 microsoft.aspnet.identity.usermanager`2.findbynameasync(string username) +177 microsoft.aspnet.identity.<validateusername> d__4.movenext() +803 system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) +93 system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) +52 system.runtime.compilerservices.taskawaiter.getresult() +21 microsoft.aspnet.identity.<validateasync> d__0.movenext() +468 system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) +93 system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) +52 system.runtime.compilerservices.configuredtaskawaiter.getresult() +24 microsoft.aspnet.identity.<createasync> d__0.movenext() +846 system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) +93 system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) +52 system.runtime.compilerservices.configuredtaskawaiter.getresult() +24 microsoft.aspnet.identity.<createasync> d__d.movenext() +1113 system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) +93 system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) +52 system.runtime.compilerservices.taskawaiter`1.getresult() +24 microsoft.aspnet.identity.asynchelper.runsync(func`1 func) +228 microsoft.aspnet.identity.usermanagerextensions.create(usermanager`2 manager, tuser user, string password) +260 dal.register.register() in c:\users\paul\documents\visual studio 2013\projects\emptywebsite\dal\register.cs:20 emptywebsite.controllers.homecontroller.index() in c:\users\paul\documents\visual studio 2013\projects\emptywebsite\emptywebsite\controllers\homecontroller.cs:20 lambda_method(closure , controllerbase , object[] ) +101 system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +59 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +435 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +60 system.web.mvc.async.actioninvocation.invokesynchronousactionmethod() +76 system.web.mvc.async.asynccontrolleractioninvoker.<begininvokesynchronousactionmethod> b__36(iasyncresult asyncresult, actioninvocation innerinvokestate) +36 system.web.mvc.async.wrappedasyncresult`2.callenddelegate(iasyncresult asyncresult) +73 system.web.mvc.async.wrappedasyncresultbase`1.end() +136 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +102 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) +49 system.web.mvc.async.asyncinvocationwithfilters.<invokeactionmethodfilterasynchronouslyrecursive> b__3c() +117 system.web.mvc.async.<>c__displayclass45.<invokeactionmethodfilterasynchronouslyrecursive> b__3e() +323 system.web.mvc.async.<>c__displayclass30.<begininvokeactionmethodwithfilters> b__2f(iasyncresult asyncresult) +44 system.web.mvc.async.wrappedasyncresult`1.callenddelegate(iasyncresult asyncresult) +47 system.web.mvc.async.wrappedasyncresultbase`1.end() +136 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +102 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethodwithfilters(iasyncresult asyncresult) +50 system.web.mvc.async.<>c__displayclass28.<begininvokeaction> b__19() +72 system.web.mvc.async.<>c__displayclass1e.<begininvokeaction> b__1b(iasyncresult asyncresult) +185 system.web.mvc.async.wrappedasyncresult`1.callenddelegate(iasyncresult asyncresult) +42 system.web.mvc.async.wrappedasyncresultbase`1.end() +133 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +56 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeaction(iasyncresult asyncresult) +40 system.web.mvc.controller.<beginexecutecore> b__1d(iasyncresult asyncresult, executecorestate innerstate) +34 system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +70 system.web.mvc.async.wrappedasyncresultbase`1.end() +139 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +59 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +40 system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +44 system.web.mvc.controller.<beginexecute> b__15(iasyncresult asyncresult, controller controller) +39 system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +62 system.web.mvc.async.wrappedasyncresultbase`1.end() +139 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +59 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +40 system.web.mvc.controller.endexecute(iasyncresult asyncresult) +39 system.web.mvc.controller.system.web.mvc.async.iasynccontroller.endexecute(iasyncresult asyncresult) +39 system.web.mvc.mvchandler.<beginprocessrequest> b__4(iasyncresult asyncresult, processrequeststate innerstate) +39 system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +70 system.web.mvc.async.wrappedasyncresultbase`1.end() +139 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +59 system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +40 system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +40 system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +38 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9514928 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155

can help me find simple way seperate models ui project?

thanks

paul

i managed around problem after trying next :

moving asp.net identity model class library http://www.umbraworks.net/bl0g/rebuildall/2013/10/22/moving_asp_net_identity_model_into_another_assembly

i did seek , and tried many similar ways although found starting fresh, deleting database , specifying specific db location helped. have later thought perchance turning on info migrations have resolved issue. still dependent on connection string in web.config not decoupled otherwise seems work

thanks

entity-framework authentication asp.net-mvc-5 decouple

No comments:

Post a Comment