PassionateDeveloper
PassionateDeveloper

Reputation: 15138

How to override the SaveChangesAsync of any DbContext globaly?

I want to override the

public virtual Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);

of any DbContext in my solution globaly and change it to

public virtual Task<MyDatabaseReturnModel> SaveChangesAsync(CancellationToken cancellationToken = default);

Is that possible?

Upvotes: 0

Views: 310

Answers (1)

mm8
mm8

Reputation: 169160

Is that possible?

No. You can't change the signature of a method by overriding it. You can only change the implementation. The SaveChangesAsync method must still return a Task<int> or int. This is how it is defined.

Upvotes: 2

Related Questions