Our tooling currently runs code in Startup.cs to get the context from services. This is messy though because our design time environment is not the same as the environment the app really runs in. We need to revisit this.
As part of this we need to try and remove ASP.NET specific dependencies from our general commands package so you don't get references to Microsoft.AspNetCore.Hosting.* etc in a UWP/WinForms/WPF project (see #4830).
Related issues: