Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Entity Framework Code First

Hi,

I'm trying to write my first project for Entity Data Model with Code First approach.

My project is composed in 3 part:

EFDemo a console project
Demo.data a class library about my object model
Demo.dataAccess a class library  about my DbContext

The error viewable in the image attached, is not understandable for me.
Please  suggest me where to find the trouble

Thanks




namespace Demo.Data
{
    public class Attendee
    {
        [Key]
        private int AttendeeID { get; set; }
       
        [StringLength(50)]
        private string LastName { get; set; }

        private DateTime DateAddeted { get; set; }


    }
}

namespace Demo.DataAccess
{
    public class CodeContext : DbContext
    {
        public CodeContext() :
            base("Server=.;Database=CodeStock;Trusted_Connection=true")
        {      
   
        }    

        public DbSet<Attendee> Attendees { get; set; }
    }
} My error
0
vgruppo
Asked:
vgruppo
1 Solution
 
IrzanaCommented:
The property has to be public, try this


[Key]
        public int AttendeeID { get; set; }
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now