> For the complete documentation index, see [llms.txt](https://cnahmet.gitbook.io/asp-net-notlarim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cnahmet.gitbook.io/asp-net-notlarim/orm-entity-framework-core/veri-tabanindan-kayit-silme.md).

# Veri Tabanından Kayıt Silme

```aspnet
static void DeleteProduct()
        {
            using(var db = new ShopContext())
            {
                // Select işlemi kullanarak silme
                var p = db
                .Products
                .FirstOrDefault(i=>i.Id == id);

                if(p != null)
                {
                    db.Products.Remove(p);
                    db.SaveChanges();

                    Console.WriteLine("Veri silindi");
                }
                
                // Entity ile kayıt silme
                var p = new Product(){Id=3};
                db.Products.Remove(p); // -> db.Entry(p).State = EntityState.Deleted;
                db.SaveChanges();
            }
}
```
