dotnet / dotnet/efcore

Get pending migrations using .NET Core CLI

Open
#28,283 3 comments 1 reaction 0 assignees View on GitHub
area-migrations customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Hello guys!

First of all, thank you so much for so great tool.

My question is can I get pending migrations using .NET CLI?

In code I can use method [DbMigrator.GetPendingMigrations](https://docs.microsoft.com/en-us/dotnet/api/system.data.entity.migrations.dbmigrator.getpendingmigrations?view=entity-framework-6.2.0)
Example:
```C#
var migrations = dbContext.Database.GetPendingMigrations();
if (migrations.Any())
db.Database.Migrate();
```

But I can't find the same method in [the CLI](https://docs.microsoft.com/en-us/ef/core/cli/dotnet).
My case is simple I need during my CI pipeline check if there are any pending migration I'll create [executable bundle](https://docs.microsoft.com/en-us/ef/core/cli/dotnet#dotnet-ef-migrations-bundle) and publish it. Otherwise, I can always create a bundle and try to update my db. But I need more controls about changes and I need to understand if there are any migrations or not.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.