Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 数据库第一个EF dnx EF dbcontext scaffold命令失败_C#_Entity Framework - Fatal编程技术网

C# 数据库第一个EF dnx EF dbcontext scaffold命令失败

C# 数据库第一个EF dnx EF dbcontext scaffold命令失败,c#,entity-framework,C#,Entity Framework,使用dnx ef dbcontext scaffold命令后,我收到以下错误: Unable to identify the primary key for table 'dbo.Report'. Unable to generate entity type for table 'dbo.Report'. 当前SQL架构 CREATE TABLE [dbo].[Report]( [ReportID] [int] IDENTITY(1000,1) NOT NULL,

使用dnx ef dbcontext scaffold命令后,我收到以下错误:

Unable to identify the primary key for table 'dbo.Report'.
Unable to generate entity type for table 'dbo.Report'.
当前SQL架构

 CREATE TABLE [dbo].[Report](
        [ReportID] [int] IDENTITY(1000,1) NOT NULL,
        [ReportName] [varchar](50) NOT NULL,
        [StoredProcedureID] [int] NOT NULL,
        [FileRepositoryID] [int] NULL
    ) ON [PRIMARY]

有人能告诉我哪里做错了吗?

您的ReportID列未设置为主键。只要简单地添加主键约束就可以了

CREATE TABLE [dbo].[Report](
    [ReportID] [int] PRIMARY KEY IDENTITY(1000,1) NOT NULL,
    [ReportName] [varchar](50) NOT NULL,
    [StoredProcedureID] [int] NOT NULL,
    [FileRepositoryID] [int] NULL
) ON [PRIMARY]

成功了!非常感谢你!我应该更仔细地阅读-_-@FBaez51发生在我们最好的人身上!总是一些简单的事情哈哈。很高兴我能帮忙