Reputation: 10071
I am doing database-first development in Entity Framework 7. When I generate my DbContext from the command line using
dnx ef dbcontext scaffold [connection string] EntityFramework.MicrosoftSqlServer -o Models -c SomeContext
it is created with an OnConfiguring(options)
method that hard-codes the connection string I used to create the model into the context. I don't want this, because I want to use this code in multiple environments with different connection strings and, according to the documentation, OnConfiguring
has the highest precedence of all the ways of specifying configuration for a context.
Can I cause dbcontext scaffold
not to output the OnConfiguring
method?
Upvotes: 4
Views: 323
Reputation: 26813
You cannot currently customize the code scaffolded by EF Core. There is a workitem on EF to track this enhancement, which is currently in the backlog. See Issue #4038 on GitHub.
Unfortunately this means you need to manually edit the code EF generates.
Upvotes: 1