2

I'm using the ADO.NET Entity Data Model (EF Designer from database), which will generate the following class from my database table "customer":

namespace WebApp1.Models
{
    using System;
    using System.Collections.Generic;

    public partial class customer
    {
        public int id { get; set; }
        public string name { get; set; }
    }
}

I would like it to add a [Key] attribute to primary key fields on generation, like:

[System.ComponentModel.DataAnnotations.Key]
public int id { get; set; }

How can it be done?

The primary key appears in the .edmx file, but is not added to the customer class

niklas
  • 21
  • 3

0 Answers0