Error generating <DbContext>

I am using MVC4 beta. The project is in VS11, EF 5.0-Beta using a Code First approach. Created a simple poco and DbContext class with a single IDbSet <> property for the model class. Connection string with LocalDb.

I noticed that when the contextual Entity Set property is of type IDbSet <> then I get a message from VS when I try to create a new controller using "Controller with actions and read / write views using Entity Framework template": "Creation failed" MyProject .MyNamespace.MyContext ". Try rebuilding your project." Not even the Clean Solution and the building help again.

If I change the Entity Set property to type DbSet <>, then the forest changes. Is this a bug or is it expected?

Br, Lauri


source to share

1 answer

It is not a bug that you cannot instantiate the interface. i before IDbSet denotes the type as interface (by convention). So you were trying to instantiate this interface. Instead, you need to handle it with DBSet <>, which is an implementation of the IDBSet <> interface. Hope this clears up your problem.



All Articles