I've got some problem with DbContext
. I decided to make a new class, which will be responsible for connections with DataBase.
public class PetAlertContext : DbContext
{
public PetAlertContext() : base("PetAlert") { }
public DbSet<Zwierze> Zwierzaki { get; set; }
public DbSet<Osoba> Osoby { get; set; }
public DbSet<Placowka> Placowki { get; set; }
public DbSet<Ogloszenie> Ogloszenia { get; set; }
}
}
But I have some exception near the name of base:
Argument 1: cannot convert 'string' to 'Microsoft.EntityFrameworkCore.DbContextOptions'.
I found a similar issue and response with some code like this, but I have a little problem with understanding this construction.
Would You be so kind to help me with that? I commented these out:
public PetAlertContext(string connectionString) : base(GetOptions(connectionString))
{
}
private static DbContextOptions GetOptions(string connectionString)
{
return SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options;
}