Consider I have a context
Adding directly data via the
DbContext is new to the
DbContext in Entity Framework Core and have no equivalents in previous version of Entity Framework where the
DbContext is available (i.e. EF 4.1 onwards).
But there is no difference because:
When you use either version of Add the context begins tracking the entity that was passed in to the method and applies an EntityState value of Added to it. The context also applies the same EntityState value of Added to all other objects in the graph that aren't already being tracked by the context.
Also there is a generic version of
Add<TEntity>(TEntity entity)) but as Visual Studio also suggests you can omit the type parameter because the compiler will infer the type from the argument passed in to the method.