I am learning .Net and am making a hotel booking system but I get the error (The Type or namespace ApplicationDbContext could not be found) but the thing is I have an ApplicationDbContext class in my data directory. How do I access ApplicationDbContext for my model here?
Room.cs
ApplicationDBContext.cs
Room.cs
C#:
public class Room
{
public int Id { get; set; }
public int Name { get; set; }
public int Location { get; set; }
public int Type { get; set; }
public string[] Types => new string[] { "First Class", "Second Class", "Third Class" };
[NotMapped]
public virtual List<Room> Rooms => new ApplicationDbContext().Rooms.ToList();
public virtual List<Room_Usage> Usages => new ApplicationDbContext().Room_Usage.ToList().where(x => x.Room_id == Id).toList();
}
ApplicationDBContext.cs
C#:
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<hotel_reservation.Models.Guest>? Guest { get; set; }
public DbSet<hotel_reservation.Models.Room>? Room { get; set; }
public DbSet<hotel_reservation.Models.Room_Usage>? Room_Usage { get; set; }
}