Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Core FromSqlRaw mock test cases

I am creating a integration test for api method which have some query like below

public async static Task<IEnumerable<T>> ForSysAll<T>(this DbSet<T> dbSet,int id) where T : class
{
    return await dbSet.FromSqlRaw($"SELECT * FROM dbo.TableName Where Id = {0}",id).ToListAsync();
}

This is working fine while I run with API code. But when I am trying to debug/run with test case. It throws an exception which is :- System.NotImplementedException : Unhandled method: FromSqlOnQueryable

Can anyone having any idea for this?

like image 427
Bunty Choudhary Avatar asked Oct 15 '25 19:10

Bunty Choudhary


1 Answers

InMemory database is not a relational database and doesn't support raw SQL execution. Link.

like image 51
Backs Avatar answered Oct 17 '25 08:10

Backs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!