0

I'm using entity framework 5 and have two Visual Studio 2010 solutions. One is a small test solution with one project and one is a much larger solution with multiple projects where I'm doing the actual business application.

The entities in the smaller solution have both the .Load() method and the .Local property.

The entities in the larger solution have neither.

I've referenced both system.data.entity and EntityFramework in the projects.

I've compared the two solutions and can't figure out what is missing in the large one. Any pointers in what direction to look next would be appreciated.

StillLearnin
  • 1,391
  • 15
  • 41
  • Is it possible that larger one is using DbContext and POCO entities while the smaller one is using ObjectContext and entities are derived from the EntityObject class? – Pawel Oct 31 '12 at 21:21
  • @Pawel it is actually the other way around as far as DbContext and ObjectContext are concerned. Please see my answer below. If you want to write up your own answer and I like its explanation better, I'll accept your answer instead of mine since you pointed me in the right direction. Thanks! – StillLearnin Nov 01 '12 at 13:44

1 Answers1

0

Prompted by the comment from Pawel, I discovered that the smaller solution is based on DbContext which gives me the .Load() method and the .Local property.

To switch the larger solution to DbContext, I followed these steps from this webpage http://msdn.microsoft.com/en-US/data/jj206878

Next, we need to swap our model to generate code that makes use of the DbContext API, which was introduced in later versions of Entity Framework.

  1. Right-click on an empty spot of your model in the EF Designer and select Add Code Generation Item…

  2. Select Online Templates from the left menu and search for DbContext

  3. Select the EF 5.x DbContext Generator for C#, enter "YourChoiceOfName" as the name and click Add

I now have the .Local property and I suspect the .Load() method is available as well although I haven't used it yet.

Community
  • 1
  • 1
StillLearnin
  • 1,391
  • 15
  • 41