关于add migration 报错的问题解决方案

  • The current CSharpHelper cannot scaffold literals of type 'Microsoft.EntityFrameworkCore.Metadata.Internal.DirectConstructorBinding'. Configure your services to use one that can.
    解决方案:程序包管理控制台->Install-Package Microsoft.EntityFrameworkCore.Design
  • Unable to create an object of type 'ActivityDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<ActivityDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
    修改Program
    before:
    public class Program
        {
            public static void Main(string[] args)
            {
                CreateWebHostBuilder(args).Build().Run();
            }
    
            public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
                WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>();
        }
    
    now:
    
            public static void Main(string[] args)
            {
                BuildWebHost(args).Run();
            }
    
            public static IWebHost BuildWebHost(string[] args) =>
                WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>()
                    .Build();
        }

     

posted @ 2018-09-21 14:38  雨V幕  阅读(686)  评论(0)    收藏  举报