I have this sample code:
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Models; namespace MySampleNamespace {
Porting from EF6 to EFCore, we had this issue. Our cause was .HasKey now returns a KeyBuilder and the .ToTable doesn't operate on it. So reversing that worked.
.HasKey
KeyBuilder
.ToTable
Ie. Was:
mp.HasKey(m => m.Id) .ToTable("Table")
Became:
mp.ToTable("Table") .HasKey(m => m.Id);