2017-10-19 111 views

回答

0

事實證明,與DOTNET的MVC核心2.0答案在於把不應該由工具來運行任何代碼,進入主的Program.cs作爲BuildWebHost是工具執行的唯一代碼。

public static void Main(string[] args) 
    { 
     var host = BuildWebHost(args); 

     // Code placed here will not be executed by EF tooling as it calls BuildWebHost directly 

     host.Run(); 
    } 

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