I created REST API's in .NET 5 and everything was working perfectly, but recently I moved to .NET 6 and realized that no startup.cs class is present. How do I add the DB Context in .NET 6 since there is no startup.cs?
In .NET 6 Microsoft has removed the Startup.cs class. Just go to the program.cs file and there you can add a connection string then you have to use builder.Services.AddDbContext
The old way is
services.AddDbContext
Just use builder.Services
and then you can achieve what you want.