简体   繁体   中英

Adding an ADO.NET Entity Data Model throws build errors

I am using Visual Studio 2013 express. I create a new project and then I add a database to that project. But, when I add an ADO.NET Entity Framework model to that project and then run the program, I get the following four build errors listed below. To try to remedy this myself, I added the namespaces 'System.Data.Entity' and 'System.Data.Entity.Design', but that didn't help. Also, I uninstalled and re-installed the Nuget package. I also uninstalled and re-installed Visual Studio 2013 Express for Windows Desktop. But these measures didn't help the situation either.

Please note that I used to use the Entity Data model just fine. But it was around the time that I did a system restore on my computer, and when I updated VS 2013 with an update offered on the start page, and finally, when I signed up for MS Azure, that I started running into the problem described above. Now I would think that uninstalling and reinstalling Visual Studio 2013, and then installing the 'Nuget' Package would solve all problems. What am I missing here?

The errors mentioned above are:

Error 1 The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?) C:\\Users\\John\\documents\\visual studio 2013\\Projects\\Riches\\Riches\\RichesModel.Context.cs 14 30 DataLayer

Error 2 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) C:\\Users\\John\\documents\\visual studio 2013\\Projects\\Riches\\Riches\\RichesModel.Context.cs 16 52 DataLayer

Error 3 The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?) C:\\Users\\John\\documents\\visual studio 2013\\Projects\\Riches\\Riches\\RichesModel.Context.cs 23 49 DataLayer

Error 4 The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?) C:\\Users\\John\\documents\\visual studio 2013\\Projects\\Riches\\Riches\\RichesModel.Context.cs 28 16 DataLayer

Thank you and I realize that my last attempt at this question was rather rough-draftish,

John

By opening 'Tools', 'Nuget Package Manager', 'Manage Nuget Package bySolution', then in 'Updates' uninstalling the check-boxes that show my dbase and its one table, and then, in the 'online' section, reinstalling with the purple-colored icon for the entity framework, then all of the references populated in the solution explorer for the EF and data extensions. And the compiler can find the library it needs to run. So the program runs fine now with the EF model added.

That other error window that you mentioned which was re: NuGet.VisualStudio.Interop I had gotten before I added Nuget at all. It was your pointing to adding Nuget to a particular solution that directed me to look in the 'Manage Nuget Package by Solution' item.

The evidence points to needing to install all of the updates manually, particularly from the Nuget Package Manager in addition to installing Visual Studio 2013 (Express). Say, for instance, if you have to restore your system to a point before you ran the update from your start screen. So in this case that you don't have access to that update from your start screen, you would now have to install VS 2013, then install Nuget from either 'tools' 'extensions and updates' or from 'tools' 'Nuget Package Manager', then install 'Entity Framework' from 'Manage Nuget Package by Solution'.

John

Install Entity Framework package by Package Manager Console. Open it (tools menu) and type:

Install-Package EntityFramework

Then let us know is it work now. (Entity Framework should be visible, when you expand References node in Solution Explorer)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM