question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davkeancommented, Mar 9, 2020

This fix has been merged.

1reaction
finalcutcommented, Mar 9, 2020

all credit to @nordvall for the repo project but thanks for fixing it @davkean

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework Core: Is it safe to delete Migration. ...
cs files from our project, dbContext.Database.GetPendingMigrations().Count() returned 0. We solved this problem by adding these attributes.
Read more >
Error while Add-Migration "Initialize" in .NET 6 Entity ...
The issue was, my startup project was chosen wrong. Fixing: I fixed it by setting the web project as a startup. You can...
Read more >
Upgrading an existing .NET project files to the lean new ...
Is there any way to get rid of the entries that Visual Studio still adds to the csproj file? For instance our .net...
Read more >
Migrating InfoPath 2007 forms with code behind to ...
In InfoPath 2013 Designer, open your template (.xsn file) and go to File > Advanced Form Options > Programming and make sure the...
Read more >
Files being added to ItemGroup.Compile[Remove]
ASP .Net Core 2.2.6 adds Migration & Migration.Designer CS files to csproj file while performing remove-migration in Package mnager Console.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found