Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
mvc multiple tables in single context entity framework
Yadlapalli Srikanth
Jun 27 2014 11:31 PM
3.3k
Reply
Dear All,
I am learning Mvc, In db context i added one more dbset,it is working fine when it is with one dbset but when i added one more Dbset getting the below error.Kindly suggest me how to work with multiple tables with in one Dbcontext
public class EmployeeContext:DbContext
{
public DbSet<Employee> Employees { get; set; }
public DbSet<Department> Departments { get; set; }
}
error
An exception of type 'System.Data.Entity.ModelConfiguration.ModelValidationException' occurred in EntityFramework.dll but was not handled in user code
Additional information: One or more validation errors were detected during model generation:
MVCP.Models.Department: : EntityType 'Department' has no key defined. Define the key for this EntityType.
Departments: EntityType: EntitySet 'Departments' is based on type 'Department' that has no keys defined.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Opeing non mdi form
Form not allowed to move or choose another form in C# ?