I have silverlight application that uses Model on a client.
I also have mobile clients that connect to the same server (WCF REST)
I'm using EntityManager on server as well but get errors like:
An EntityManager can only execute on a single thread. This EntityManager is authorized to execute on the thread with id=’13’; the requested operation came from the thread with Id=‘14’.
Consider calling the EntityManager’s asynchronous methods; they work safely on background threads managed by DevForce.
You may have to disable this cross-thread checking for specific reasons such as automated testing. Please review our documentation on multi-threading issues and the EntityManager.AuthorizedThreadId property.
What does it mean and how do I work with it? Prior to getting DevForce we used EF and there was no issues like this. We don't want to maintain 2 models with the same stuff and converted to DevForce.
Mobile service looks like this:
[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class MobileService
{
[Import]
public IContextManager ContextManager { get; set; }
[Import]
public IMembershipService MembershipService { get; set; }
So, that means I'm having instance per call. However my ContextManager and MembershipService shared and I guess this is where the problem is. I understand I can make them non-shared. Or is there other way to solve this problem?
I realize that I probably should do single instance per-call which means I should use NonShared on all of my DI-objects.
I wonder how DevForce will perform in such scenario? I have very light DB calls (small inserts) but there is a lot of calls. Up to 1000 per minute which means I will have to create EntityManager instance every time. Is that a big load? Or it will be fine?
Edited by katit - 01-Feb-2012 at 2:51pm