Skip to main content

EF: Dynamic DBContext

We've created library that fits the following use cases:

  • Provides an Entity Framework DbContext.
  • Works with these backends:
    • MSSQL
    • Postgres
    • SQLite
    • In-Memory
  • Compatible with NET Core 5, 6, and 7.
  • Makes use of reflection where possible, to avoid hard 

Project Info

The GitHub repo is here: https://github.com/ogauto/OGA.DynamicDomain.Lib

The JIRA page is here: 

The Jenkins Job is here: http://192.168.1.200:8080/job/oga-jobs/job/Libraries/job/Build-OGA.DynamicDomain.Lib/

Avoiding Library References

This library uses reflection, when possible, to avoid hard references to other libraries.

Logging

Specifically, this library avoids a hard reference to "Microsoft.EntityFrameworkCore.Relational", when setting up EF logging.
Normal EF logging setup requires hooking to EF events, such as:

  • CommandExecuting
  • CommandExecuted
  • CommandError

These events are defined in Microsoft.EntityFrameworkCore.Relational.
So, the library loads it, via reflection, to setup logging for EF events.

 

EF Logging

We are able to hook into Entity Framework logging by