EF报错:Unable to create an object of type 'XXXXXXX'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
这个是在EF迁移的时候报错:
解决方案:
修改你的MyDbcontext:
代码如下:
public class StoreDbContexttFactory : IDesignTimeDbContextFactory< ‘你的类名’> { public ‘你的类名’CreateDbContext(string[] args) { var optionsBuilder = new DbContextOptionsBuilder< ‘你的类名’>(); optionsBuilder.UseSqlServer("server=.;uid=sa;pwd=123456;database=Ceshi123123"); return new ‘你的类名’(optionsBuilder.Options); } }
然后再次迁移:
ok成功!