Skip to main content

EF: Dynamic DBContext

We've created a 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.

EF Logging

Specifically, thisThis library avoidsimplements a hardmethod reference to "Microsoft.EntityFrameworkCore.Relational", when setting up EF logging.
Normalof EF logging setupthat requiresallows 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 ableus to hook into EntityEF Frameworkevents loggingand byfilter for ones of log-able interest, that are sunk to our existing NLog logging.

Details are on this page: EF: Logging