Skip to content

Is there any way to setup NetPad to use our DbContext defined in our project dll, like LINQPad Entity Framework Core Driver #72

Answered by jwallet
jwallet asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I actually found out the solution:

.UseNpgsql to work with my PostGreSQL database

var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>();
optionsBuilder.UseNpgsql("YOUR_CONNECTION_STRING", x =>
  {
  x.EnableRetryOnFailure();
});
var dbContextOptions = optionsBuilder.Options;

// specify all injected depedencies, mine was DbContextOptions and an optional Mediator
var _appDbContext = new AppDbContext(dbContextOptions, null);

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jwallet
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants