I created an ASP.NET Core 1 project and using .Net Core 1.0 framework. And want to use the Entity Framework 6.
I follow this tutorials https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html and when I try to migrate with the statement:
PM> Add-Migration MyFirstMigration
then it shows me:
The EntityFramework package is not installed on project 'IndustryCloud'.
It is possible to use EF6 with ASP.NET Core 1?
You can use Entity Framework 6
with ASP.Net Core 1.0. An example application can be found on Github.
In order to make it work, you have to follow the instructions from the repo (below I paste the crucial parts, but I encourage you to check the ones from repository):
Inside project.json:
- Remove netcoreapp1.0 from the target frameworks and add net451.
- Remove everything EF Core and add Migrator.EF6.Tools + EF6 to your dependencies
Inside Startup.cs:
- Remove everything EF Core related.
- Simply add your db context to services:
services.AddScoped<ApplicationDbContext>();
Next:
Remove the "Migrations" or the "Data/Migrations" folder that EF Core generated.
And finally:
dotnet ef migrations enable
dotnet ef migrations add InitialCreate
dotnet ef database update
Note that you can use another project called MR.AspNet.Identity.EntityFramework6 to bridge Asp.Net Core Identity with Entity Framework 6.
you cannot use Entity Framework 6
with .Net Core 1.0. There is a Entity Framework Core 1.0
package developed specifically for .Net Core 1.0
. You need to install it to use in .Net Core 1.0 project.
https://blogs.msdn.microsoft.com/dotnet/2016/06/27/entity-framework-core-1-0-0-available/
Install using Nuget Package Mangager Console.
PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer
Add a new migration (If it’s the first one, it will add the neccessary folder structure and classes)
dotnet ef migrations add {MigrationName}
Remove the most recent migration.
dotnet ef migrations remove
Update the database the latest version (apply all migrations)
dotnet ef database update
http://benjii.me/2016/05/dotnet-ef-migrations-for-asp-net-core/
You can find so many articles in google.