EF Core脚手架dbContext表中未包含选择集中的表



我最近升级为.net core 2.0,我遇到了很多脚手架的问题。

首先,当我运行时

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

我会收到以下错误。这真的让我感到困惑,因为我的数据库中没有uk_principal_name索引?

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.

所以我尝试从这样的数据库中指定想要的表。

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

我得到了以前遇到的错误以及此错误。

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

当选择表中不包含表格时,这是什么意思?在以前版本的.NET Core上,我没问题运行此脚手架命令,它将抓住我的所有表并在模型中为它们生成代码。

事实证明我的问题是我正在使用SQL Server 2005,而脚手架dbcontext在该版本上使用dbo.sysdiagrams有错误。必须返回旧版本的.net。

这些不仅仅是警告,因为在解决此问题之前,我无法踩踏我的模型。

最新更新