Entityframework.docs: Document 5.0 RC1 build warnings due to obsolete method in old migrations

Created on 15 Sep 2020  路  3Comments  路  Source: dotnet/EntityFramework.Docs

Since EF Core 5.0 now is RC1, I thought I'd start testing it for our application.

Unfortunately, I get a lot of build warnings in old migration designer files (from early 2017) due to an obsoleted method HasName, see the following error:

warning CS0618: 'RelationalIndexBuilderExtensions.HasName(IndexBuilder, string)' is obsolete: 'Use HasDatabaseName() instead.'

I tried to re-read the blog posts and breaking changes documents, but could not find any mention about this.

What is the suggested steps here? Is there any tool available to upgrade old migrations? Am I supposed to do any manual upgrade steps, if so - which? I'm not very happy with having build warnings left unattended.

Further technical details

EF Core version: 5.0.0-rc.1.20451.13
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Win10 2004
IDE: Visual Studio 2019 16.7.2

area-migrations closed-fixed type-breaking-change

Most helpful comment

Best thing to do for pre-2.0 migrations is add pragma same way how it is generated in new migration files. Methods used will be marked obsolete but not removed so they wouldn't require to be changed.
See https://github.com/dotnet/efcore/issues/8703#issuecomment-306848595

All 3 comments

Best thing to do for pre-2.0 migrations is add pragma same way how it is generated in new migration files. Methods used will be marked obsolete but not removed so they wouldn't require to be changed.
See https://github.com/dotnet/efcore/issues/8703#issuecomment-306848595

Thanks @smitpatel that seems to work.

Would be nice to include this in the docs if there are others like me with old migrations.

We should add a note to the breaking changes about this.

Was this page helpful?
0 / 5 - 0 ratings