I am reverse engineering our db. I am using scaffold-dbcontext in the package manager console with the -force flag. I know for sure it is updating the files.
I have added a Primary key in the db though and when that didn't work I even added another Index:
The dbcontext that was created seems to have the code for the Primary Key:
modelBuilder.Entity<DealerDisclaimers>(entity =>
{
entity.HasKey(e => e.DealerDisclaimerId)
.HasName("PK_DealerDisclaimers");
However, when I try to navigate to a page that would load that table it gives the following error:
InvalidOperationException: The entity type 'DealerDisclaimers' requires a primary key to be defined.
The DealerDisclaimers class the scaffold-dbcontext builds out looks like this:
public partial class DealerDisclaimers
{
public int DealerDisclaimerId { get; set; }
public int DealerId { get; set; }
public string GeneralDisclaimer { get; set; }
public string LeaseDisclaimer { get; set; }
public virtual Dealer Dealer { get; set; }
}
Side note: If I add the [Key] attribute then it loads without the error. But I shouldn't have to manually add it, the scaffold-dbcontext command should prepare everything for me.

scaffold-dbcontextwith-DataAnnotations -Forceflags, but the[Key]attribute is not created - Ish Thomas