0

I recently upgraded to.Net Core 2.0, and I'm running into a lot of issues scaffolding an existing database.

First of all, when I run

Scaffold-DbContext "Server=mysrv;Database=mydb;User Id=uname;password=pword" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

I get the following errors. Which is really confusing me because there is no table in my database with a UK_principal_name index?

Unable to find a table in the database matching the selected table dbo.sysdiagrams.
For index PK__sysdiagrams__0CBAE877. Unable to find parent table dbo.sysdiagrams. Skipping index.
For index UK_principal_name. Unable to find parent table dbo.sysdiagrams. Skipping index.

So I tried specifying a table I want from the database like this.

Scaffold-DbContext "Server=mysrv;Database=mydb;User Id=uname;password=pword" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Table Burner

And I get the errors I had before along with this error.

Index column dbo.BurnerHistory belongs to index PK_BurnerHistory on table Burn_Hist_Idx which is not included in the selection set. Skipping.

What does it mean when it says the table is not included in the selection set? On the previous version of .NET Core I had no problem running this scaffold command, it would grab all of my tables and generate code for them in the model.

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
Tony Martinez
  • 335
  • 3
  • 16

1 Answers1

0

Turns out my problem was that I'm using SQL server 2005, and Scaffold-Dbcontext has errors with dbo.sysdiagrams on that version. Had to go back to an older version of .NET.

These weren't just warnings, because I wasn't able to scaffold my model before I resolved this.

Tony Martinez
  • 335
  • 3
  • 16