Как настроить строку подключения EF из стандартной библиотеки .NET? Нет UseSqlServer в DbContextOptionsBuilder?

Я получаю сообщение об ошибке ниже при попытке доступа к объектам в боковом контексте данных.

System.InvalidOperationException: 'No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.'

Мой код находится в стандартной библиотеке .Net, и не все методы настройки параметров доступны (что предлагается в большинстве ответов).

Ниже мой код. Я пытаюсь проверить это в консольном приложении.

ТестКод:

static void Main(string[] args)
    { 
        using (MyEntities context = new MyEntities())
        {
            var stdQuery = (from d in context.My_Employees
                            select new { Company = d.COMPANY_NAME, Emp = d.EMP_NAME });
            foreach (var q in stdQuery)
            {
                Console.WriteLine("Company Name : " + q.Company + ", Emp Name : " + q.Emp);
            }
            Console.ReadKey();
        }
    }

Код DataContext ниже (стандартная библиотека .Net)

     public partial class MyEntities : DbContext
    { 
     public virtual DbSet<My_Employee> My_Employees { get; set; }
        public virtual DbSet<My_Company> My_Companies { get; set; }

 protected override void OnConfiguring(DbContextOptionsBuilder builder)
        {
            if (!builder.IsConfigured)
            {
                string conn ="<ConnectionString>"; 
                //builder.  <There is no option to mention UseSqlServer>
            }
            base.OnConfiguring(builder);
        }
}

Любая идея, как решить эту проблему? Я действительно застрял там.


person Sachin    schedule 30.05.2020    source источник
comment
stackoverflow.com/q/43098065/2864740 - найдено с помощью уточненного запроса "выпуск" стандарта UseSqlServer .net.   -  person user2864740    schedule 30.05.2020
comment
Спасибо @user2864740. Это помогло мне решить проблему.   -  person Sachin    schedule 30.05.2020