If you are using DbContext in the program, you need to install Microsoft.EntityFrameworkCore.SqlServer in the Nuget
using ConsoleApp1.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using System; using ConsoleApp1.BusinessLogic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Startup(); Console.WriteLine("Hello World!"); } private static void Startup() { var services = new ServiceCollection(); var connectionString = "Data Source=localhost;Initial Catalog=TestDB;User ID=sa;Password=123;"; services.AddDbContext<MyDbContext>(options => options.UseSqlServer(connectionString)); services.AddScoped<IDatabaseBO, DatabaseBO>(); var provider = services.BuildServiceProvider(); using (var serviceScope = provider.CreateScope()) { the service provider = serviceScope.ServiceProvider; was databaseBO = serviceProvider.GetService <IDatabaseBO> (); databaseBO.GenerateData(); } } } }