Solved

Entity Framework Code First

Posted on 2011-09-08
1
320 Views
Last Modified: 2012-06-27
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
Comment
Question by:vgruppo
1 Comment
 
LVL 10

Accepted Solution

by:
Irzana earned 500 total points
Comment Utility
The property has to be public, try this


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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now