2017-10-19 4 views

답변

0

DotNet MVC Core 2.0을 사용하면 도구 작성으로 실행해서는 안되는 코드를 program.cs main에 넣을 수 있다는 것이 밝혀졌습니다. 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();