Can I inject dependency into migration (using EF-Core code-first migrations)?
问题 I tried to inject IConfiguration into the migration (in constructor), and got exception: "No parameterless constructor defined for this object." any workaround? 回答1: you cannot, the migrations need to be able to run outside the context of your application. Since the Entity-framework command-line tool analyzes your code but does not run the startup.cs class. Also it is not advisable. your migrations should be plain simple and not depend on anything. if it would, it could lead to major runtime