简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM