views:

23

answers:

1

Our application is using Entity Framework(.net 3.5) and singleton . When i update in the back end through procedure. It is not reflecting in the entity context.

I tried with refresh - But it is not refreshing Foreign Key.

How to refresh the entire context in Entity Framework ?

A: 

Are you trying to Singleton the objectcontext object? I don't recommend that. It is better to instantiate a new objectcontext for each "unit of work." If you do that, your "entity context" will always be up to date.

http://blogs.msdn.com/alexj/archive/2009/05/07/tip-18-how-to-decide-on-a-lifetime-for-your-objectcontext.aspx

http://stackoverflow.com/questions/813457/instantiating-a-context-in-linq-to-entities

Robert Harvey
we tried using (MyContext ctx = new MyContext()){ …}in our repositary class.But this throwing some other error for foreginkey. How to overcome that?
anishmarokey
Sounds like you might have a problem with your database table. See also http://stackoverflow.com/questions/520065/entity-framework-as-repository-and-unitofwork
Robert Harvey