VergilPrime
VergilPrime

Reputation: 33

ASP.NET Core Entity Framework code-to-database scaffolding not recognizing Id property or [Key] annotation

I'm trying to scaffold out a razor page set for my Ticket class and I'm getting an error when Entity Framework tries to create the database:

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

My understanding is that if you have a property "Id" it will use it, and if you set the [Key] annotation it will specifically tell Entity Framework to use that property. I have both of those things, so what gives?

Upvotes: 2

Views: 215

Answers (1)

Arsalan Valoojerdi
Arsalan Valoojerdi

Reputation: 1026

Make your properties public .

public int Id { get; set; }

Upvotes: 5

Related Questions