-
Hi, I'm wondering if I can use my project dll and return the dbContext from there so I can query stuff using my entities, example I have a table TimeSheets but in my dll I made two variants NonBillableTimeSheet and BillableTimeSheet models that are based on a discriminator, I can seem to only use the database collections in NetPad which does not provide those types. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Okay, I actually found out the solution:
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); |
Beta Was this translation helpful? Give feedback.
-
Currently NetPad only offers the option to build the data context automatically when adding a database connection. The ability to select an assembly that already has a data context and have NetPad use that assembly instead of its auto-generated one is not yet available, although its definitely something planned. One option is to add and reference your assembly in script properties (F4 and add your assembly), and then get your |
Beta Was this translation helpful? Give feedback.
Okay, I actually found out the solution: