I created a Service class in .Net 6. How to call it in .net 6?
.Net 6
using API.Data;
using API.Interfaces;
using API.Services;
using Microsoft.EntityFrameworkCore;
namespace API.Extensions
{
public static class ApplicationServiceExtensions
{
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config, WebApplicationBuilder builder)
{
builder.Services.AddDbContext<DataContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
builder.Services.AddScoped<ITokenService, TokenService>();
}
}
}
I was calling it as given below.
.net core 3
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationServices(_config);
}
When I try to call like this. It shows an error Can anyone suggest the right way to call it?
Program.cs .net 6
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationServices(_config);