Specifying a key in a C# class

  • Thread starter Thread starter irsharp
  • Start date Start date
I

irsharp

Guest
I am developing an ASP.NET Core Razor app(my first attempt to do so).

I'm using tutorials by Rick Anderson at docs.microsoft.com in my attempt, but I think my current hurdle is more basic.

When I attempted to run the app,

it first said I didn't have a key specified.

I then included [Key] above the key field, but I didn't yet have the proper "using" statement, so I got another error.

After discovering the need for:

using System.ComponentModel.DataAnnotations;
using System.Data;

I then included them.

I now get the following message:

There was an error running the selected the code generator:

'The entity type 'tableName' requires a primary key to be defined. If you intended to use a keyless entity type call HasNoKey()'

...but it has(!) a key.

What am I doing wrong?

Continue reading...
 
Back
Top