In .NET 6 Microsoft has removed the Startup.cs class. Now when you'll add a connection string then you've to use builder.Services. AddDbContext The old way is services.AddDbContext Just use builder.Services and then you can achieve what you want.