I am having trouble deleting an entity -
Using db As Context = New Context
Dim car = db.Car.First(Function(x) x.ID = txtCarID.text)
db.Entry(car).State = Data.Entity.EntityState.Deleted
End Using
I have tried many other syntax, here is another -
Using db As Context = New Context
Dim car = new Car With {.ID = txtCarID.text}
db.Car.Attach(car)
db.Car.Remove(car)
End Using
I have received no errors but the record is never deleted.
Where am I going wrong?
Thanks,
You need to call SaveChanges
method of DbContext
after you made the changes. Otherwise changes will not be committed to databse.