Migration "designer" file gets added to csproj with wrong case
See original GitHub issueWhen 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
- Create a migration from VS Package Manager Console:
Add-Migration mymigration -Project myproject.data -StartupProject myproject.api
- Inspect the files produced on disk:
- Migrations\20200131080738_mymigration.cs
- Migrations\20200131080738_mymigration.Designer.cs
- Inspect the myproject.data.csproj file:
<Compile Include="Migrations\20200131080738_mymigration.cs" />
<Compile Include="Migrations\20200131080738_mymigration.designer.cs" />
- 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (7 by maintainers)
This fix has been merged.
all credit to @nordvall for the repo project but thanks for fixing it @davkean