I'm new to Asp.net and created a web application using MVC5 in Asp.Net. And I have a quick question like can we create DbContext with two models(As shown in below image).
From above code, I can able to apply CRUD operations to Employee model.. But I'm getting this exception:
System.Data.SqlClient.SqlException: Invalid object name 'dbo.User Details'
For UserDetails model, and I'm suspecting that it is happening only because of two models in one DbContext.. Is my approach is correct or not?
please help me..
It may be to do with pluralizing database names. In your EmployeeContext class try
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
Example: