I was trying to encapsule my application into three layers using entity framework as dao.
But I see it is impossible !!
So, I start using my DbSet in controller and doing something like:
var product = new Product();
product.Name = "product name";
db.Product.Add(product);
db.SaveChanges();
But now I dont have a BL layer, so, how can I set an observer to send an email after SaveChanges()?
You can override the
saveChanegson your DBContextBut it’s not a good idea to do it in the DBContext because that is not what DbContext supposed to do. Sending email involves some business logic, it’s better if you can have it in your business layer instead of data access logic.