Print Page | Close Window

EntityManager error

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3299
Printed Date: 19-Apr-2024 at 2:11pm


Topic: EntityManager error
Posted By: alex.tiuca
Subject: EntityManager error
Date Posted: 24-Feb-2012 at 6:28am
I get this error and i don't know how to solve it. The error is thrown on this method:

public static List<TIPI_RECAPITI> GetTipiRecapiti()
        {
            var query = from q in dbContext.TIPI_RECAPITI
                        orderby q.ID ascending
                        select q;

            return query.ToList<TIPI_RECAPITI>();
        }   

An EntityManager can only execute on a single thread. This EntityManager is authorized to execute on the thread with id=’16’; the requested operation came from the thread with Id=‘12’.



Replies:
Posted By: DenisK
Date Posted: 24-Feb-2012 at 2:59pm
Hi Alex,

The EntityManager is not thread-safe. See  http://drc.ideablade.com/xwiki/bin/view/Documentation/entitymanager-not-thread-safe - http://drc.ideablade.com/xwiki/bin/view/Documentation/entitymanager-not-thread-safe .

What most likely happen is that the EM is created on another thread but is executing query on a different thread.


Posted By: alex.tiuca
Date Posted: 27-Feb-2012 at 3:01am
How can i execute queries on the same thread?


Posted By: DenisK
Date Posted: 27-Feb-2012 at 8:07pm
Well, in general, if you're doing synchronous operations, they stay on the same thread. It's a different story if you're doing asynchronous operations.

If you can upload your project here, I can take a quick look and let you know what's wrong.



Print Page | Close Window