entity framework 5.0 .load method and .local property are missing from entity

試著忘記壹切 提交于 2020-03-04 23:01:27

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13167563/entity-framework-5-0-load-method-and-local-property-are-missing-from-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!