Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 247
Vaccano Avatar asked Dec 06 '22 05:12

Vaccano


1 Answers

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

like image 81
Vaccano Avatar answered Feb 04 '23 20:02

Vaccano