Skip to content

EF Migrations assembly build time went from ~30 seconds to ~4 minutes after installing VS 16.8 #23291

@augustoproiete

Description

@augustoproiete

I have a solution with projects targeting netstandard2.1 and netcoreapp3.1 that takes about ~40 seconds to run a full rebuild on Visual Studio 16.7 and prior versions.

After installing Visual Studio 16.8 - and without making any changes to any of the projects, the build time now increased to about 4 minutes 👀 but only when building via Visual Studio... If I run dotnet build on the solution, I get back to the ~40 seconds to run.

I was able to narrow it down to the assembly that contains the EF database migrations. If I exclude this project from the build, it finishes in less than 10 seconds (which means the EF migrations assembly takes ~30 seconds on VS 16.7 and prior).

VBCSCompiler appears to be hanging for a long time, but eventually the build finishes.

image

Is this a known issue? I was able to find some comments about analyzers slowing the build (i.e. analyzers running on the EF migrations generated code) could that be the case, and what is the workaround (if any)?


DatabaseModels.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.9">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.9" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.9" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
  </ItemGroup>
</Project>

DatabaseMigrations.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\DatabaseModels\DatabaseModels.csproj" />
  </ItemGroup>

</Project>

global.json

{
  "sdk": {
    "allowPrerelease": false,
    "version": "3.1.100",
    "rollForward": "latestFeature"
  }
}

EF Core version: 3.1.9
Database provider: Microsoft.EntityFrameworkCore.NpgSql 3.1.4
Target framework: .NET Core 3.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions