Q: Prevent Starting Angular On EF Migrations The problem is that when the db context is in the start up project, when i apply migrations using Update-Database visual studio is stuck on ng Serve.
Note that i have modified Program.cs in orders for the migrations to run.

output of PM> Update-Database



*

*Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]

*User profile is available. Using C:\Users\Mozart\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.

*Microsoft.AspNetCore.SpaServices[0]

*Starting @angular/cli on port 49488...

*Microsoft.EntityFrameworkCore.Infrastructure[100403]

*Entity Framework Core 2.0.0-rtm-26452 initialized 'VegaDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
Microsoft.AspNetCore.SpaServices[0]

*
Vega@0.0.0 start D:\Tutorials\Vega\Vega\ClientApp


*
ng serve --extract-css "--port" "49488"


Program.cs

public class Program
{
    //public static void Main(string[] args)
    //{
    //    CreateWebHostBuilder(args).Build().Run();
    //}

    //public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    //    WebHost.CreateDefaultBuilder(args)
    //        .UseStartup<Startup>();
    public static void Main(string[] args)
    {
        var host = BuildWebHost(args);
        host.Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}


Startup.cs

  public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<VegaDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Default")));

            services.AddMvc();

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });
        }
    }

Currently i restart visual studio to resolve this issue.

A: I figured out that the problem only occurs while application is running, either using Ctrl F5 or dotnet run so i had to exit IIS i.e terminate it's process.
So it is related to code hot tracking.
