Skip to content

Customizing Add and AddRange #728

Answered by thepirat000
abplocker asked this question in Q&A
Discussion options

You must be logged in to vote

Internally, DbSet.AddRange invokes the same method as Add within a foreach loop:
Source: EF Core - InternalDbSet.cs (Line 567)

There is no way to determine whether an entity was added via Add or AddRange.

You could potentially implement your own DbSet<T>, but it’s not as simple as inheriting from DbSet<T> and adding custom logic:
Related discussion on Stack Overflow.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@abplocker
Comment options

@thepirat000
Comment options

Answer selected by abplocker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants