c# working with Entity Framework in a multi threaded server

后端 未结 6 781
北荒
北荒 2020-11-29 00:11

What is the best practice for working with entity framework in a multi threaded server? I\'m using entity framework ObjectContext to manage all my database acti

6条回答
  •  忘掉有多难
    2020-11-29 00:52

    I create a new Context for each atomic operation and dispose the context. As far as i know from books and articles, i prefer to keep life time of Context as short as possible. (but it depend on you approach and you application type, winform or web)

    Please find more information at great article. http://www.west-wind.com/weblog/posts/2008/Feb/05/Linq-to-SQL-DataContext-Lifetime-Management

    Good books: http://books.google.co.th/books?id=Io7hHlVN3qQC&pg=PA580&lpg=PA580&dq=DbContext+lifetime+for+desktop+application&source=bl&ots=ogCOomQwEE&sig=At3G1Y6AbbJH7OHxgm-ZvJo0Yt8&hl=th&ei=rSlzTrjAIovOrQeD2LCuCg&sa=X&oi=book_result&ct=result&resnum=2&ved=0CCgQ6AEwAQ#v=onepage&q&f=false

    Existing discussion at Datacontext Lifetime in WinForm Binding Scenario

提交回复
热议问题