How to add an implementation of IDesignTimeDbContextFactory to add migration to .Net core 2.0 application?

后端 未结 3 1059
眼角桃花
眼角桃花 2021-01-17 21:16

I am trying to run Add-Migration InitialCreate command from package manager console from a .NET Core 2.0 MVC application. After looking at all possible sources still not abl

3条回答
  •  青春惊慌失措
    2021-01-17 21:45

    You need change your class Program

    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }
    
        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup()
                .Build();
    }
    

    This class changed with dotnet core 2.0.0

提交回复
热议问题