How to enable entity framework in a project in visual studio 2013 C# mvc project? - entity-framework

I am trying to enable entity framework in visual studio 2013. My project is a c# mvc project which is newly created. I have installed entity framework using package manager. Now when I am trying to enable the entity framework, I am getting this error
PM> Enable-Migrations
No context type was found in the assembly 'MVCWebApplication'.
PM>
How can i solve this?

Related

EF6 Entity Data Model Designer not available with target framework .net 5.0

I have an existing .NET Framework-based solution that I'm migrating to .net 5.0. I'm not migrating data access just now: we'll keep using EF6 model-first. After converting projects to .net 5.0 I've tried opening the .edmx file only to get a message:
The Entity Data Model Designer is unable to display the file you requested.
The Entity Framework is not available in the target framework currently specified for the project. You can change the target framework of the project or edit the model in the XML Editor.
The target framework is net5.0.
Should this work?
No, as per EF docs:
There's currently no support for using the EF designer directly on
.NET Core or .NET Standard projects or on an SDK-style .NET Framework
project.
Thanks to #ErikEJ for a detailed walkthrough of a workaround.

"Microsoft.Data.Entity" dll not found in nuget

For one of my projects i am using asp.net mvc core and in this web application, for using EntityFramework i am not able to download 'Microsoft.Data.Entity' from nuget.
you have to install 2 package using the package manager
Microsoft.EntityFrameworkCore.SqlServer
Then in your code, require it:
using Microsoft.EntityFrameworkCore;
The package you need for EF Core is:
Microsoft.EntityFrameworkCore.SqlServer
It was due to ASP.Net Core framework was not installed correctly, i tried it in Visual Studio 2017 and guess what it worked perfectly.

Database first generation Entity Framework 5 System.Data.Entity vs EntityFramework

Trying to use Visual Studio 2012, Entity Framework 5.0 database first approach to generate my edmx.
When I generate the EDMX from the database VS 2012 - says
Successfully registered the assembly 'System.Data.Entity, Version=4.0.0.0;
web.config file as well says
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral.../>
I see EntityFramework and System.Data.Entity both listed in the references. EntityFramework shows up in the packages folder and System.Data.Entity points to the .NET 4.5 install folder. Does this mean that I am succesfully using EF 5.0?
For existing project migrations - when I migrate a project from VS 2010 .NET 4.0 and set the .NET client profile to 4.5 the System.Data.Entity assembly gets upgraded to the one in .NET 4.5 install folder. I do not see the EntityFramework.dll at all. Are there any changes I would need to make in order for my existing project to mgirate to EF 5.0 and .NET 4.5
Am I missing something here?
The version of System.Data.Entity.dll assembly is the same on both .NET Framework 4 and .NET Framework 4.5. The catch is that only one version can be installed on a machine at the same time so even if you target .NET Framework 4 in your project but run your app on a machine with .NET Framework 4.5 you will effectively run it against .NET Framework 4.5 (and therefore the EF5 version of System.Data.Entity.dll assembly).
With regards to EntityFramework.dll - up to the version 6 it was build on top of System.Data.Entity.dll (in EF6 the code from System.Data.Entity.dll and EntityFramework.dll was merged and further evolved). If you used EntityFramework.dll in VS2010 it means that it had to be one of the 4.x versions which were EF4. You could continue to use it even with the EF5 version of System.Data.Entity.dll but you will not be able to take the advantage of new features introduced in EF5 (like enums, spatial etc.). Since you decided to move to .NET Framework 4.5/EF5 you should also update your EntityFramework.dll 5.0.0.0. To do that you have to install the NuGet extension (http://docs.nuget.org/docs/start-here/installing-nuget) if you have not already and just install EntityFramework.dll using the package manager console (http://www.nuget.org/packages/EntityFramework/5.0.0). It should replace the 4.x version you have in your project with 5.0.

MVC 4 Application Using Entity Framework

I recently did a portion of the MVCMusicStore tutorial using MVC3 as directed. However, being that I have Visual Studio 2012, I'm attempting to use EF in an MVC4 application. I was attempting to add the using System.Data.Entity; directive and it was not found.
I know that I can probably just add the reference to it. But I'd like to know why it's not already available for my MVC4 project. Is there a new method of creating an Entity Framework supported application using MVC4?
Entity Framework is now being distributed separately from Visual Studio through the NuGet package management system as of Visual Studio 2012. The reason for this is to decouple EF from the release of VS, so it can be released on a different time schedule. They have also recently released EF as an open source framework, so it's being removed as a project from the .net framework release.
You have to use NuGet to install Entity Framework in your project. Right click on the project and choose Manage Nuget Packages. Make sure you select the Online tab in the dialog that opens, then in the search type Entity Framework and click Install. You will then be able to add the using statement.

Install Entity Framewok v5 in Webmatrix 2 RC

I'm working on a project with Entity Framework in Webmatrix 2 RC, so I need to use Entity Framework v.5 RC because of conflicts between previous versions and .NET Framework 4.5.
The two ways I know to install NuGet packages in Webmatrix are from the NuGet Gallery on the Webmatrix ribbon and from the package manager in ASP.NET Web Pages Administration: either solution proposes only Entity Framework v4.3.1.
I have downloaded Entity Framework v.5 RC with the Package Manager Console of Visual Web Developer and copied the EntityFramework.dll into the bin folder of my project.
This solution works but I wonder if exists a way to install a not recommended NuGet package that doesn't require the use of Visual Web Developer.
You can use nuget.exe or NuGet Package Explorer, both are standalone and lightweight. You'll still have to manually add references to the files though.