SelectMany in Entity Framework is an operator which flattens out the collection of collections into one single collection of objects. It is a very useful operator with many use cases.
Include method in Entity Framework has two overloads. One of which takes navigation property as a string. The other one is Include lambda method. The Include Lambda method is an extension method from the namespace System.Data.Entity. In this tutorial, we look at include method, and learn how to load entities from multiple levels and multiple tables.
List of Best Entity Framework Books
Updating Records Logging in EF Learn how to delete records from the database using Entity Framework. Deleting an entity is done using the Remove or RemoveRange method of the DbSet. Alternatively, you can also set the entity state as Deleted. We can delete records either in connected or disconnected Scenarios. We will also look at […]
Learn how an entity framework update records to the database. We can update records either in connected or disconnected scenarios. In the connected Scenario, we open the context, query for the entity, edit it, and call the SaveChanges method. In the Disconnected scenario, we already have the entity with use. Hence all we need to is to attach/add it to the context. Set its State as Modified and then call the SaveChanges But we need to be careful in a disconnected scenario as the update will update all the fields, Hence a chance of accidentally overwriting a field. We also show you how to update multiple records & Related Data etc.