왜 오류가 발생했는지는 분명하지 않습니다. 내가 처음 프로젝트를 비계 할 때 마이그레이션 및 업데이트 데이터베이스 명령은 잘 돌아 갔지만 응용 프로그램을 거의 변경하지 않은 후에는 this error이되었습니다. 주위에 떠있는 유일한 해결책은 this입니다 :'TContext'에 매개 변수없는 생성자가 없습니다.
public class BloggingContextFactory : IDbContextFactory<BloggingContext>
{
public BloggingContext Create()
{
var optionsBuilder = new DbContextOptionsBuilder<BloggingContext>();
optionsBuilder.UseSqlite("Data Source=blog.db");
return new BloggingContext(optionsBuilder.Options);
}
}
내 DbContext :
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplicationDbContext
{
public DbSet<ApplicationUserCode> ApplicationUserCodes { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
그것은 나를 위해 작동하지만 연결 문자열을 하드 코딩 나와 함께 잘되지 않습니다 클래스 안에 있습니다. 이 오류가 한 번에 발생하지 않은 이유에 대한 명확한 설명은 클래스에 연결 문자열을 포함시키는 것보다 훌륭한 솔루션이며 또한 훌륭한 솔루션입니다.
내 게시물을 DbContext의 모양으로 업데이트했습니다. – lbrahim
내 StartUp 및 DbContext 코드 [여기] (https://github.com/aspnet/EntityFramework/issues/7641#issuecomment-290339592)를 찾을 수 있습니다. – lbrahim