Search code examples
entity-frameworklinqpad

Can I get at the DbContext created by LinqPad?


I am trying to test my IRepository interface via linqpad. To make one I have a constructor that looks like this:

IRepository dataAccess = new GenericRepository(dbContext);

This works fine in my own code, but I don't know how to get at the dbContext in linqpad. (I would rather not create my own if I don't have to.

All my code uses IRepository (so that I can unit test). I can't test it in LinqPad unless I can make a GenericRepository using the dbContext.

Any idea how I can get at the DbContext that LinqPad creates?


Solution

  • I just needed to set the connection to my EF Connection. After that I could use the this keyword and it worked.