Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private T GetContext<T>() where T : DbContext
var options = new DbContextOptionsBuilder<T>().UseNpgsql(connection).Options;
return (T) typeof(T).GetConstructor(new Type[] { typeof(DbContextOptions<T>) }).Invoke(new object[] { options });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment