using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
public class BloggingContext : DbContext
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlServer(@"Server=.\SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;");
protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
public int BlogId { get; set; }
public string Url { get; set; }
public bool Removed { get; set; }
public List<Post> Posts { get; set; } = new List<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; }
public static void Main()
using var context = new BloggingContext();
var query1 = context.Set<Blog>()
var query2 = context.Set<Blog>()
.Where(x => x.Removed == false)
Console.WriteLine("Usando !Removed");
Console.WriteLine(query1.ToQueryString());
Console.WriteLine("-----------------");
Console.WriteLine("Usando Removed == false");
Console.WriteLine(query2.ToQueryString());