question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EF Core 3.1: New Overrides

See original GitHub issue

Protip: When supporting EF Core 3.1, mocked DbSet<> objects need to additionally override the newly-added methods .AsQueryable() and .AsAsyncEnumerable() (which simply return this;) within BuildMockDbSet() calls.

Anyone who (like me) was using the .AsQueryable() extension method upon a DbSet<> in production code will, after upgrade to 3.1, be calling the methods upon DbSet<> instead. In my case, this meant that instead of getting a cast of the DbSet<> to IQueryable<> I was getting an auto-generated default implementation from Moq’s DefaultValueProvider, which is basically Array.Empty<T>.AsQueryable().

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
krilllindcommented, May 23, 2021

@likemike91 Created a new ticket and PR. Hopefully we can get this fixed 👍

1reaction
likemike91commented, Mar 19, 2020

Is that also fixed for NSubstitute? Unfortunately I get the same error when using NSubstitute and I didn’t see the fix in the code of the NSubstitute extension?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking changes included in EF Core 3.x
Complete list of breaking changes introduced in Entity Framework Core 3.x.
Read more >
Creating and Configuring a Model - EF Core
Overview of creating and configuring a Entity Framework Core model via ... the latest call will override previously specified configuration.
Read more >
EF Core - Overriding conventions - YouTube
Entity Framework Core is all about conventions. That's how the entire EF Core magic happens out of the box. However, there are a...
Read more >
OnModelCreating code refactoring from EF6 to EF core 3.1
According to your code, it seems that you want to change the Table Name and set the Column Name, if that is the...
Read more >
Override EF Core DbContext in ASP.NET ...
It replaces the EF Core DbContext with a DbContext using the InMemoryProvider. After migrating to 3.0 it isn't replaced anymore. I always ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found