Skip to content

Commands: Error gracefully on non-relational providers #1652

@adamvoss

Description

@adamvoss

When migrations are not available because of the data store (provider) configuration, the failure message is not very helpful in indicating the issue. Ideally the failure message when migrations are not available would communicate the failure is because of the data store configuration and provide hints/suggestions as to how to go about correcting the issue.

Given a project with only the following classes:

public class BlogDbContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Blog>();
    }
}

public class Blog
{
    public int BlogId { get; set; }
    public string Url { get; set; }
}

An attempt to create a migration with Add-Migration fails with the following message:

Unable to resolve service for type 'Microsoft.Data.Entity.Commands.Migrations.MigrationScaffolder' while attempting to activate 'Microsoft.Data.Entity.Relational.Migrations.Infrastructure.MigrationAssembly'.

Desired behavior might be a message along the lines of (example text only):

Migrations are unavailable because the configured data store does not support Migrations.

or

Migrations are unavailable because no data store configuration was found.

Either better conveys the issue in form the user's perspective. Information about how/where configuration can be done would make them even better. There might also be value in keeping the technical information as well for debugging and such?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions