Reputation: 263
I am learning Insert ,update, delete using Entity Framework in MVC from
I add new Entity Framework and after that adding new Controller.
here is my Setting for adding new Controller
when I save adding Controller . Error Comes ..
There was an error generating 'MvcApplication1.Models.EmployeeContext'. Try rebuilding your project.
EmployeeContext.cs
public class EmployeeContext :DbContext
{
public DbSet<Employee> Employees { get; set; }
}
(Employee class is in seperate Assembly)
Solutions i tried :
it says some special constructor in dbcontext caused problem... i dont have any
3.Database.SetInitializer() placed in Application_Start method in Global.asax.cs
whats Wrong ? please suggest ...
Upvotes: 1
Views: 5002
Reputation: 263
OK , Resolved .. Here what i did
I removed Model Class , Context Class and add , delete , save operations ..which were manually created . Entity Framework Auto Generates these things . so the conflict was occuring...
while adding New controller ..In DataContext Class Section ..Connectionstring name should be filled which is Auto Generated by Entity Framework . i was filling incorrect thing
Hope that might be helpful
Upvotes: 1