Using ADO.NET's Entity Framework with visual studio 2010 and NuGet - what's really happening - visual-studio-2010

I'll need to use ADO.NET EF for my next project so I started a tutorial but ended up with installing Entity Framework while my Project was open through Project -> Manage NuGet Packages and then decided to walk through the tutorial using another project so I closed the current one and on the next day I created new Console Project for the needs of this tutorial. However when I tried to add using System.Data.Entity; to my Program.cs it didn't recognize the Entity so I had to install again Entity Framework from NuGet which seems kind of strange to me.
Is this how it should be - installing the Entity Framework for every project that will use it or I can install it once and then add it as reference where needed or something like that like many other packages in .NET?

No, you shouldn't need to install Entity Framework for each project. Did you try adding a reference to the missing DLL? To do this, right-click your project in Solution Explorer and select Add Reference from the menu. You should be able to select System.Data.Entity from the .NET tab:

Related

Entity Framework not appearing in Add New Item list in Visual Studio 2017

I created a new MVC project in Visual Studio 2017. I wanted to add an EDMX file (I will be doing database-first) so right clicked on the project and selected Add|New Item.
However, I cannot find the Entity Framework components that were available in the previous versions of Visual Studio. Does anyone know where they went?
I had a similar issue today after i updated my VS to the latest 2017 version. I tried to open an .edmx file in VS2017 and it didn't show the designer view. So i realised i forgot to select Entity Framework tools during the installation:
Everything is back to normal :)
In .NET Framework-based projects, the Entity Framework 6 templates are still there. However, for .NET Core-based projects, I believe you're expected to use the dotnet ef commands. This includes a means of scaffolding a code-first DbContext from an existing database. See ASP.NET Core - Existing Database.
To verify this, I setup a demo project with the following structure:
The New Item/Data dialog for the .NET Framework project:
Note that there is also an EF POCO Generator template available in the Online templates section that may be of interest to you:
I know this is late, but I ran into the same exact issue. After reading some of the other answers, I realized I had created a .Net project with Standard library instead of the Framework library.
I faced this issue, while creating an MVC application on my latest installation of VS2017.
Failed:
Tried installing Entity Framework using Nuget package manager[Install-Package EntityFramework], but failed to show Ado.NET Entity data model
Success:
1. open programs under control panel and select Visual Studio 2017
2. select Change the installation
3. Select Modify installation
4. Select Individual components
5. If SQL server data tools already installed, deselect/uninstall this component and reinstall the same again.
6. uninstall and reinstall SQL Server Data tools
Note: with one component change, other components may also be deleted. You have to recheck while reinstalling

Missing "Ado.Net Entity Data Model" on Visual Studio 2013

I have created new web project but I can't find ADO.net Entity DAta Model to add it.
How to fix it or Install it ?
Go to "C:\ProgramData\Package Cache" and search for "EFTools.msi".
You should find two files, just install the most recent one (it should be about 960KB). This fixed the problem for me.
i have the same problem, but there is no "EFTools.msi" in "C:\ProgramData\Package Cache" for me...
UPDATE :
i download and install "Entity Framework 6 Tools for Visual Studio 2012 & 2013" and it solved the problem \m/
Download Link
Some web tutorials show a 'ADO.NET data entity model' item in the 'Models->Add' menu. In VS2015 this menu item is not shown. You need to keep drilling down by selecting 'New Item...' and then further selecting 'Data' from the pop-up dialog.
My solution was none like the above.
The .msi file was nowhere in the folders suggested in prior answers, nor doing a search in my hard drive found any EFTools.msi instances.
So the failsafe approach came through this article (since the author appears to have completely removed the page from the server, I've changed the URL to a version of the page stored in Google's cache), which was poorly written by a chinese fella, so I'm gonna try to rewrite the steps in a clearer way:
The solution is as follows:
Open your VS2013 installation ISO (or pop the DVD in) and navigate to "\packages\EFTools" folder;
There you will find 2 files (a .cab file and a .msi file);
Copy both files to a directory on your hard drive;
[Optional]: You can create in that same directory, an empty .txt file ("Log.txt") so that the installation log output will be redirected to it later;
Open a MS-DOS command prompt (with administrative rights) and type the command: EFTools.msi USING_EXUIH=1 /log "Log.txt" [NOTE: If you did not perform step #4, then you do not need to type from the ' /log' on (inclusive)]
Wait patiently while the installation process finishes. Takes quite some time (guess never hurts to remind you that this needs to be done with VS2013 closed). The installation should go fine, anything weird will be logged into the text file (the one you created in step #4).
Or, you might just double-click the .msi file if you are feeling brave..
After installation, open VS2013 and try adding a new item to the Models folder. The "ADO.NET Entity Data Model" should have reappeared under the "Data" tab.
Recognition goes to the anonymous chinese poster on that link (er, "Melinda"?) - xiè-xiè!
Be sure you are trying to do that in .Net Framework project. For example, when you are creating a project do not use a template called Windows Forms App (.Net Core), use Windows Forms (.Net Framework). The (.Net Framework) extension is important.
right click on your project--> properties---> framework target select 4.5 and should work.
It's only for Visual Studio 2012. For me this had no effect on 2013.
For the record, if you have Visual Studio 2015 RC, the "EFTools.msi" can't be downloaded from Microsoft
If you accidentally delete the "ProgramData" folder, the Repair option will not work, you have to use the Add or Remove features option from the installer, and check the SQL Server Data Tools
Make sure the type of project you've added is for .NET Framework and not for .NET Standard. The templates for adding things such as ADO.NET Entity Data Model are included for .NET Framework.
For Visual Studio 2017 the following works.
Create project:
Create new project of type 'Class Library'
Install 'Entity Framework' from NuGet
Now add datamodel:
In project click 'Add New Item'
Select 'Visual C# Items' -> 'ADO.NET Entity Data Model'
I recently added Entity Framework and installed in one of my many projects in a single sln file.
The thing is Entity Framework works on Framework higher than 3.5.
So Class Library of NET Standard wouldn't support Entity Framework, thus missing Ado.Net Entity Data Model, Since NET Standard console Library is Framework 2.0, changing the class Library to .NET Framework one, will include Ado.Net Entity Data Model.
I had the same issue, but found out that I was selecting ASP.NET Core web App, ASP.NET Core web App(MVC) etc, Instead Choose ASP.NET Web Application (.NET Framework) and you will get the ADO.NET Entity Data Model option.
Go to visual studio installer.
Add:
Entity framework tool 6
Download and install it.

Can't add a reference to EntityFramework in my unit test project

I have a new project happily using Entity Framework 5. After I added the edmx to the solution, it added a reference to EntityFramework version 5.
I created a unit test project, and I need to use something from the EntityFramework library. However, there is no reference to EntityFramework. When I go to Add Reference, I cannot find it anywhere in the list.
I've checked and my unit test is referencing .NET 4.5. Any idea why I can't add the reference?
Remove all the entries you have made to the web.config file. Just Right Click on your project name in the solution, Click on Manage Nuget Packages On your left hand Click on Online and on the right hand just put Entity Framework in the search box. Click on Install
this will do all the things automatically for you.
Answer is taken from: EntityFramework 5 Install fails in VS 2012
I had the same problem with a new application. I opened the Package Manager Console and used install-package EntityFramework, which installed version 6 without issue.
Just Adding System.Data.Entity might not enough;
because by this you are trying to referencing something that has not been installed yet.
this issue can be resolved by installing EntityFramework.
So to do this :
Go to Solution Explorer
Right Click on Your Project Name
Select "Manage NuGet packages"
Now Install the Entity Framework.
You need to add a reference to "System.Data.Entity" dll at References folder of your Unit Test project.

how can i use Entity Framework 4.1 in Visual Studio 2012?

I have a web application on a web farm and i use .NET 4 and entity data model 4.1.
when i started working on this web application i used visual studio 2010, and today i have uninstalled it and installed new version (Visual Studio 2012).
Due to some reasons, i have deleted my ado.net entity data model to recreate it, but i
pay attention that visual studio 2012 use entity framework 5 not 4.1. I have updated it but in old model i can context constructor to change my connection string but in this new model have no constructor, is that true?
I have installed EF 4.1 but it doesn't works and I've added version 5 to my project.
Background info: my web application is on a shared host and i can not update it to EF 5.
How can i use entity framework 4.1 in visual studio 2012 ?
is that possible? if yes, how?
Remove Existing (Entity framework 5)
Remove the existing reference (to Entity framework 5) under the References section in your Project in Solution explorer.
Remove the corresponding entry from your packages.config file. If you open the packages.config file, you will see an xml structure and you will see an element with id EntityFramework with version attribute value as 5.0.0. Remove that line( that package element).
Add Again (Entity framework 4.1)
Now go to the package manager window(View->Other Windows -> Package Manager Console) and execute the following command there.
Install-Package EntityFramework -Version 4.1.10331.0
This will download EF 4.1 to your project and you will see the success message like below.
Reference : http://nuget.org/packages/EntityFramework/4.1.10331.0
Always keep in mind that there are a lot of improvements made in EF 5. So consider to consume all those as possible as you can.

Automatic project references update in VS2010

Are you tired of checking if a newer version of the library you're using has been released, or when you update to new versions, change all references in all csproj projects?
For example, I have many csproj projects using those references:
<HintPath>..\..\..\Referencias Externas\Microsoft.Practices.EnterpriseLibrary 4.1\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll</HintPath>
...more...more...
<HintPath>..\..\..\Referencias Externas\Unity 1.2\Microsoft.Practices.Unity.dll</HintPath>
...more...more...
<HintPath>..\..\..\Referencias\Company\2.0\Company.Common.dll</HintPath>
Now, I would like use new versions, EnterpriseLibrary 5.0, Unity 2.1, NHibernate 3.2, etc, and references to Company Framework (Company.Common.dll, etc), but I need changes all references in many,many projects.
any extension in VS2010 for do it easy and quick?
I would like any like ProjectConverter - Auto update DevExpress references http://www.devexpress.com/Support/Center/p/Q308968.aspx
Reference:
http://feedback.wovs.com/forums/71955-extension-ideas/suggestions/1003595-automatic-reference-update
Use the package manager nuget to manage your dependencies.
NuGet is a Visual Studio extension that makes it easy to install and update third-party libraries and tools in Visual Studio.
As a workaround, you could create a library project that does the handling and forwards access to the .dlls and every other project uses this one. Then you only need to update the .dll references in this one wrapper project.

Resources