Strange behaviour with StructureMap / ASP.MVC / Visual Studio / LinqToSql

前端 未结 4 1583
梦如初夏
梦如初夏 2020-12-18 05:45

I have been using the new MVC framework with StructureMap recently and have had good results overall, however, I keep running into a very strange error that I cannot underst

4条回答
  •  粉色の甜心
    2020-12-18 06:19

    I was talking to Jeremy Miller about this and you don't want to manage the lifetime of the db context with SM - let the repo instantiate as needed. This presents problems with how you will do object updating/persistence (if you're relying on a context staying alive for more than one request) but it's worth it to not rely on this for a web app.

    I had to remove the db context management stuff from the storefront for a reason like this - I was getting memory leaks. I won't say it's SM's fault - but overall just let the repo open a new context.

提交回复
热议问题