Efcore: __EFMigrationsHistory cannot be renamed?

Created on 16 May 2017  路  2Comments  路  Source: dotnet/efcore

I am trying to configure the name of the dbo.__EFMigrationsHistory table using the following (within OnModelCreating):

```c#
builder.Entity().ToTable("MigrationHistory", "Auth");


However, when trying to create the migration, I get an error indicating lack of primary key:

dotnet ef migrations add SpecifyMigrationsHistoryTableName
...
System.InvalidOperationException: The entity type 'HistoryRow' requires a primary key to be defined.


I see that the HistoryRow class within Microsoft.EntityFrameworkCore.Migrations is defined as...

```c#
public virtual string MigrationId { get; }

(whereas in EF6 it was defined as...)

c# public string MigrationId { get; set; }

Given that DbMigrationsConfiguration is apparently not supported in EF Core (https://blogs.msdn.microsoft.com/dotnet/2016/09/29/implementing-seeding-custom-conventions-and-interceptors-in-ef-core-1-0/), is there a workaround?

Further technical details

EF Core version: 1.1.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Similar issue on StackOverflow: http://stackoverflow.com/questions/40886158

closed-question

Most helpful comment

All 2 comments

@bricelam Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings