I am new to EF and I start with EF5.
Following the recommendations of the Performance Recommendation for Entity Framework 5 , 2.4.2 Moving your model to a separate assembly ... I created a split project (I will call it EfPrj) to manage my Db context (called MyDbContext).
In my domain layer (I will call it DomainPrj) I use entities from EfPrj. The problem is that inside DomainPrj I do not see MyDbContext members inherited from DbContext.
For example, if I want to update the Users table, the code will be as follows:
void UpdateUser(User u) { MyDbContext db = new MyDbContext();
But in EfPrj it works without problems. In DomainPrj, I don't see the SaveChanges () member function, getting this error:
'MyDbContext' does not contain a definition for 'SaveChanges' and no extension method 'SaveChanges' ... could be found (are you missing a using directive or an assembly reference?)
Update: EfPrj es is just an ORM Database-First project. By default, MyDbContext is defined as an EF5 object: public partial class MyDbContext: DbContext {public MyDbContext (): base ("name = MyDbEntities") {}
So it comes from DbContext and is publicly available. Links DomainPrj EfPrj and MyDbContext db = new MyDbContext() work without problems.
source share