0

Help me please! I have project on ASP.NET MVC, EF 4.5 and WCF services. Problem is that data from database are not loading to View. I traced host WCF project with debugger and saw logs in SvcTraceViewer and I saw similar errors for entities(which are not loading), but I cant stand what they mean.:

Image with error description. My errors

Community
  • 1
  • 1
Dmitry Pyatin
  • 419
  • 1
  • 7
  • 17
  • Can you please provide some of the code of your service and the exact version of EF and .NET you are using? (e.g. there is no EF 4.5) – divega Oct 16 '12 at 03:28

1 Answers1

0

Check the connection string in the WCF project.

For reference:

The context cannot be used while the model is being created

EF CTP4 : "The context cannot be used while the model is being created."

Community
  • 1
  • 1
Smudge202
  • 4,689
  • 2
  • 26
  • 44
  • Connection string is correct. When I refresh web page some entities are loading, but some aren't loading (different entinies anytime). – Dmitry Pyatin Oct 09 '12 at 15:30
  • Do you have a singleton context or some form of request based lifetimes? – Smudge202 Oct 09 '12 at 15:38
  • I am sorry, I newbe in this field, and only began to study this technologies, so I didn't understand your question =( I have Repository in one project(Data), and WCF services in another project(Host), Client application(Site) use WCF services from Host for loading data into controllers, then data loading with javascript into page. My Repository, service and controller example: http://pastebin.com/TL0Y8ScM (In debug I have exception on Repository.Get();) – Dmitry Pyatin Oct 09 '12 at 16:04
  • What line inside Repository.Get() fails? My previous question, more layman's, is how do you store your database context? If the context is stored in such a way that it _lives_ longer than, or shorter than the application that is using the context, it can cause the error you've had. I see that you are injecting the context, so you may need to specify the lifetime of the object that you are injecting. Which dependency injection container are you using? (Ninject, Unity, etc?) – Smudge202 Oct 10 '12 at 08:27