C# 无法在ASP.NET Core 5.0 c中获取DBContext的反射类型#

C# 无法在ASP.NET Core 5.0 c中获取DBContext的反射类型#,c#,asp.net-mvc,asp.net-core,asp.net-mvc-scaffolding,C#,Asp.net Mvc,Asp.net Core,Asp.net Mvc Scaffolding,我将ASP.NET Core 5.0 MVC与最新版本的c#和VS2019社区一起使用,我不断收到一个错误 我试图: 重建项目 将c#版本更改为6/7/7.1 重新安装VS2019 以及您在之前的文章中提供的一些其他解决方案,这些解决方案适用于VS2019和ASP.NET Core 2.0,但错误仍然存在 问题仍然存在 这是我的一些代码 MyDb上下文 public class MyDbContext : DbContext { public MyDbContext(DbC

我将ASP.NET Core 5.0 MVC与最新版本的c#和VS2019社区一起使用,我不断收到一个错误

我试图:

  • 重建项目
  • 将c#版本更改为6/7/7.1
  • 重新安装VS2019
  • 以及您在之前的文章中提供的一些其他解决方案,这些解决方案适用于VS2019和ASP.NET Core 2.0,但错误仍然存在
问题仍然存在

这是我的一些代码

MyDb上下文

public class MyDbContext : DbContext
{

    
   public MyDbContext(DbContextOptions<MyDbContext> options) : base(options)
    {
    }

    public DbSet<TestTabel> testTabels { get; set; } 
    public DbSet<User> Users { get; set; }
    public DbSet<Client> Clients { get; set; }
    public DbSet<Owner> Owners { get; set; }
    public DbSet<Admin> Admins { get; set; }
    public DbSet<Hotel> Hotels { get; set; }
    public DbSet<Chambre> Chambres { get; set; }
    public DbSet<BonReservation> BonsReservations { get; set; }
    public DbSet<ListHotelOwners> ListHotelOwners { get; set; }
    public DbSet<Address> address { get; set; }
    public DbSet<Roles> Role { get; set; }

    /// <summary>
    /// Add indexs and unique keys to all tables 
    /// </summary>
    /// <param name="modelBuilder"></param>
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        //User Table
        modelBuilder.Entity<User>()
            .HasIndex(u => u.NomUtilisateur)
            .IsUnique();
        modelBuilder.Entity<User>()
            .HasIndex(u => u.NomPrenom)
            .IsUnique();
        modelBuilder.Entity<User>()
            .HasIndex(u => u.NumTelephone)
            .IsUnique();

        // Role Table
        modelBuilder.Entity<Roles>()
            .HasIndex(r => r.Nom).IsUnique();

        //Address Table

        modelBuilder.Entity<Address>()
            .HasIndex(a => a.Maison).IsUnique();



    }
}
项目结构 ''

错误
''

你在说什么错误?此外,该社区要求将代码作为文本,而不是截图,当然也不是截图的链接放在问题中。这是否回答了您的问题@布莱恩德林格:我试过了,但问题还是一样,我在屏幕上加了一个短镜头error@Crowcoder我在问题中添加了代码和错误截图
public class TestTabel
{
    
    public int Id { get; set; }
    [Column(TypeName = "varchar(30)")]
    public string username { get; set; }
    [Column(TypeName = "varchar(30)")]
    public string Password { get; set; }
}