EF4: ObjectContext Lifetime?

前端 未结 2 898
夕颜
夕颜 2020-12-20 23:38

I am developing a WPF desktop app that uses Entity Framework 4 and SQL Compact 4. I have seen two distinct styles of Repository classes:

  • The

2条回答
  •  甜味超标
    2020-12-21 00:23

    The best practice is depended on how your users are going to use the application: And how your application is structured.

    if there is only one user using your application at one time, you can even create your entity context as a static instance.

    context can be used per request, per thread, per form.

    read more: http://blogs.microsoft.co.il/blogs/gilf/archive/2010/02/07/entity-framework-context-lifetime-best-practices.aspx

提交回复
热议问题