Skip to content
Discussion options

You must be logged in to vote

the services.AddDbContext<TContext>(...) extension just adds a little syntax sugar around registering the DbContext. It's not really magic though and you should be able to view the source from Visual Studio. By default it will register the DbContext as a Scoped service which isn't really relevant for your WPF app... you would want to look at either registering it as a singleton or possibly a Transient if you see errors with one process trying to query the database concurrantly with another process in your app. There are a few ways you could do this but you might look at something like:

var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
builder.UseSqlServer("...");
containe…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LudwigNel
Comment options

Answer selected by LudwigNel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
WPF
Labels
None yet
2 participants