-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension methods are not found while using Interface with DbContext #18442
Comments
@sudurrani In the code above, the interface |
It's very simple, there is an interface with entities and this interface is implemented by a class also inherited from DbContext.
|
@sudurrani That's because the interface doesn't define a |
@ajcvickers exactly when I add Database property then whenever I use _context.Database.ExecuteSqlCommand here I won't be able to access .ExecuteSqlCommand. |
@sudurrani Unless I'm missing something, that's just the way C#/.NET works. Is there something EF should be doing differently here? |
I found the solution. |
While using an interface for entities with DbContext class can't use/found _context.Database
Steps to reproduce
Interface
DbContext Class
Now whenever I inject IMainDbContext and use _context.Database.ExecuteNonQueryAsync is not found gives compile time error.
Further technical details
EF Core version: 3.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.3.1
The text was updated successfully, but these errors were encountered: