|
-
Aug 11th, 2013, 06:15 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Entity Framework and threading
Hi Folks
Im just getting started with EF (with SQL server) and threading.
My question is about how I should access the context for threads that work with the context?
Should I create a new context per thread or create one and lock on it from each thread that needs to use the context?
Thanks
Thanks 
-
Aug 11th, 2013, 07:05 AM
#2
Re: Entity Framework and threading
If you create multiple contexts then you will have multiple versions of the same data and that's a bad thing. An EF context is just like any other data. You wouldn't create multiple arrays or collections to be used in multiple threads so it doesn't make sense to create multiple EF contexts. If you are going to synchronise access between threads though, don't use the context itself. It's always good practice to create an object solely for the purposes of locking.
-
Aug 11th, 2013, 08:04 AM
#3
Thread Starter
Hyperactive Member
Re: [RESOLVED] Entity Framework and threading
Thanks Jn
Thanks 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|