Skip to content

Migration "designer" file gets added to csproj with wrong case #5956

@nordvall

Description

@nordvall

When I perform Add-Migration from Visual Studio, the following files are created in my project directory:

  • {datetime}.{migrationname}.cs
  • {datetime}.{migrationname}.Designer.cs

These files are also registred in the csproj file for the project (is it really needed?). However, the Designer.cs file is added with lower case 'd', like {datetime}.{migrationname}.designer.cs

This becomes a problem when I try to build my project on a Linux machine in Azure Pipelines:

CSC : error CS2001: Source file '/home/vsts/work/1/s/{project directory}/Migrations/{datetime}.{migrationname}.designer.cs' could not be found. [/home/vsts/work/1/s/{project directory}/{project name}.csproj]

As you know, Linux usually has case sensitive file systems, which consider this file as non-existing.

Steps to reproduce

My setup is a VS Solution with two projects

  • myproject.data: A .NET Standard 2.1 Class library project
  • myproject.api: An asp.net core 3.0/.net core 3.0 project
  1. Create a migration from VS Package Manager Console:

Add-Migration mymigration -Project myproject.data -StartupProject myproject.api

  1. Inspect the files produced on disk:
  • Migrations\20200131080738_mymigration.cs
  • Migrations\20200131080738_mymigration.Designer.cs
  1. Inspect the myproject.data.csproj file:

<Compile Include="Migrations\20200131080738_mymigration.cs" />
<Compile Include="Migrations\20200131080738_mymigration.designer.cs" />

  1. Notice the case difference between "Designer.cs" and "designer.cs"

If you want you can try to build the project with Azure Pipelines and vmImage: 'ubuntu-latest' in the yaml-file to see the error.

I develop the project on Windows, where everything works fine. The error appears further down the road, when we come to the Azure Pipelines build.

Workaround

I use to manually update the csproj file, and replace "designer" with "Designer".

Further technical details

EF Core version: 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Standard 2.1
Operating system:

  • Windows 10 (dev machine).
  • ubuntu-latest (build agent)
    IDE: Visual Studio 2019 16.3.9
    Microsoft.EntityFrameworkCore.Tools version: 3.1.1

Metadata

Metadata

Assignees

Labels

Needs-CPS-workChanges are needed in the closed-source Common Project System (CPS) repo.Resolution-FixedThe bug has been fixed, refer to the milestone to see in which release it was fixed.

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions