ASP.Net Core EntityFramework代码到数据库的脚手架无法识别ID属性或[Key]注释

问题描述 投票:0回答:1

[我正在尝试为我的“ Ticket”类创建一个razerpage集,当Entity Framework尝试创建数据库时出现错误:

This shows the error next to my "Ticket" definition which includes a Key annotation above an "Id" property

我的理解是,如果您拥有属性“ Id”,它将使用它,并且如果设置了[Key]批注,它将专门告诉EntityFramework使用该属性。我同时拥有这两个东西,那能给什么呢?

c# entity-framework-core ef-migrations ef-code-first-mapping asp.net-core-scaffolding
1个回答
1
投票

将您的财产公开。

public int Id { get; set; }
© www.soinside.com 2019 - 2024. All rights reserved.