TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sreekanth Reddy
353
4.9k
423.3k
Primary Key for model in code first approach
Nov 21 2014 8:24 AM
Hai friends, I am doing code first approach:
Here is my model class:
public class RegUsers1
{
[KEY] //but not coming. Its assigning 0 to Uid & throwing unable to save
public int Uid { set; get; }
public string FullName { set; get; }
public string Email { set; get; }
public string Password { set; get; }
public string Gender { set; get; }
public string Qualification { set; get; }
}
For this class How to set primary key to Uid? I have used the [KEY] attribute. But I am unable to trace it is throwing an error by assigning 0 to uid while inserting. Is there any other option to [KEY]? Simply my question is how to set primary key to Uid in code first approach? Thank you
Reply
Answers (
1
)
retrieving session value in layout page in MVC
Primary Key for model in code first approach