-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't locate DbContexts and DbMigrationsConfigurations that cannot be constructed #25
Conversation
… constructed. This also solves an issue where and abstract (or generic) base class is made for either types, which is inherited from in an implementation. Previously the abstract class could be located, instead of the implementation.
@@ -67,7 +67,11 @@ public void EnableMigrations(string outputDir) | |||
|
|||
private string FindAppDbContextTypeName() | |||
{ | |||
var allDbContextTypes = _types.Where(t => typeof(DbContext).IsAssignableFrom(t)); | |||
var allDbContextTypes = _types.Where( | |||
t => typeof(DbContext).IsAssignableFrom(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this a method and use it in FindDbMigrationsConfiguration
too? (it's duplicated)
Perhaps var allDbContextTypes = GetConstructablesOfType(typeof(DbContext));
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think they did that in the EF source code too. Will add it in a minute.
And @nphmuller, for your info, EF6 is now maintained at GitHub instead of codeplex! Here: aspnet/EntityFramework6. |
Thanks for the link! Edit: Ah, I misread your suggestion. If you think a method like GetConstructablesOfType() is better, I'll rewrite it. |
Looks great. But I think you used spaces in |
…extensions method.
c058a2b
to
dbe37bc
Compare
Should be all tabs now ;) |
Thanks a lot! |
When an abstract (or generic) base class is made for either types, they might be used, instead of the implementation.
Example: I have an abstract class DbContextBase and a class MyApplicationContext : DbContextBase.
Migrator.EF6 would incorrectly detect DbContextBase as the single true DbContext, instead of MyApplicationContext.
The constraint I've used are taken from the EF source code