Using EF Migration for Publishing is Only Available for Some Web Projects

I have several projects using Asp.Net Core 1.0 and Entity Framework Core 1.1.0

I have the first approach to porting code, and I'm posting it on Azure through Visual Studio 2015.

As I applied migration to Azure Sql Server, the checkbox in the publication was turned on: "Entity Framework Migrations - apply this migration when publishing", where I entered the connection string.

I updated several packages, and now for one of my projects I don’t see this option apply migrations to the publication more. I see that he is trying to discover data contexts, but finds nothing (although he is there in the same project ..)

See below:

  • A project where I can apply migrations to Azure when publishing: apply available migrations

  • A project in which there is no way to apply migration to Azure when publishing: apply migrations unavailable

I suspect this is due to some version of the dependencies for the project, and not to my IDE, because I use the same Visual Studio (2015 update 3) for both projects.

I could not find information about this. What dependence does this option allow? If I find out which version is problematic, then the remaining question is how to apply migration when publishing then?

Both projects have a migration in the web project, and both projects use "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0"

UPDATE 1 . I managed to find what is connected with this. It seems that if I use these dependencies:

 "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final" 

Visual studio can find the data context and offer the possibility of applying migration when publishing. But if I use newer versions of these dependencies, for example:

 "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", "Microsoft.EntityFrameworkCore.Design": "1.1.0" 

Then this option to apply the migration will disappear, and VS will not be able to find any data context when publishing.

I need to find out which last status is associated with the migration agent and Asp.Net Core.

+5
source share
2 answers

I came across a very similar problem (the publication does not look for data contexts inside the project for publication) in Visual Studio 2017 after creating an empty ASP.NET Core Web API project and adding migration.

To make it work, I included the following lines in the .csproj file:

 <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" /> 
+2
source

You can use the Package Manager Console (PMC) or the command line interface (CLI) to work with migrations. When using PMC, EF migrations during publication are not detected. Using the CLI, the EF migration section appears.

0
source

Source: https://habr.com/ru/post/1261743/


All Articles