Я пробовал перейти с V17 и V19, но в обоих случаях одно и то же.
Что я пытаюсь сделать :
Используя Entity Framework, я пробую подход «Code First».
Приведенный ниже код раньше работал.
(Взято из docs.microsoft)
с использованием Microsoft.EntityFrameworkCore;
Код: Выделить всё
public class BloggingContext : DbContext
{
public DbSet Blogs { get; set; }
public DbSet
Posts { get; set; }
protected override void OnConfiguring (DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
@"Server=(localdb)\mssqllocaldb;Database=Blogging;Integrated Security=True");
}
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public int Rating { get; set; }
public List Posts { get; set; }
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
}
исчезновение onconfig
Как вы можете видеть на изображении, OnConfiguring должен быть после свойства Model, но его больше нет.
Вопрос: кто-нибудь знает, почему OnConfiguring исчез из DbContext?
Подробнее здесь: https://stackoverflow.com/questions/642 ... st-anymore