Online Training for MVC Web Designing Development, MS SQL, Digital Marketing

Delete data using Entity Framework Core

Here we learn how to delete data using entity framework core
How Delete works in EF Core
As I said in earlier tutorial that EF Core API can keep track of all the entities retrieved using the context, so when you delete or remove any data from context object and finally call the SaveChanges() method, all new changes made to context gets saved to database, thus data gets deleted from database also.

In entity framework core the delete method is replaced with remove();

Deleting single table using EF Core

public bool DeleteStudent(int stuid)
bool _isDeleted = false;
Student _s = null;
var context = new EFContext();
_s = context.tbStudent

if (_s != null)
_isDeleted = true;

return _isDeleted;

Deleting from multiple tables using EF Core

Deleting multiple records using EF Core

Delete example in EF Core

Group Training