Another \'Entity Type \'x\' has no key defined\' question, but I\'ve set the [Key]
attribute on a property so I\'m a bit confused.
Here\'s my entity and con
To help clarify, this line:
public string GMCNumber;
needs to become:
public string GMCNumber { get; set; }
You need to change GMCNumber
to a property not a field.
I ran into this post after facing a similar issue today. The problem was that I was attempting to create the scaffold after adding the [Key] attribute to my model and without compiling. Once I compiled with the [Key] attribute the scaffolding generated just fine.
I encountered the same error message when I had defined the property as private.