-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
In NET6 EF Core I get an compile error if I use the method FromSqlRaw \ FromSqlRawAsync when both of the following NuGet Packages are installed:
- Microsoft.EntityFrameworkCore Version="6.0.0-rc.2.21480.5"
- Microsoft.EntityFrameworkCore.Cosmos" Version="6.0.0-rc.2.21480.5"
The error is:
Code CS0121
The call is ambiguous between the following methods or properties: 'Microsoft.EntityFrameworkCore.RelationalQueryableExtensions.FromSqlRaw<TEntity>(Microsoft.EntityFrameworkCore.DbSet<TEntity>, string, params object[])' and 'Microsoft.EntityFrameworkCore.CosmosQueryableExtensions.FromSqlRaw<TEntity>(Microsoft.EntityFrameworkCore.DbSet<TEntity>, string, params object[])'
Example code
public void TestDemo()
{
//SETUP
var options = SqliteInMemory.CreateOptions<MyDbContext>();
using var context = new MyDbContext(options);
context.Database.EnsureCreated();
//ATTEMPT
var query = context.MyEntities.FromSqlRaw("SELECT * FROM MyEntities"); //THIS LINE HAS ERROR
//... rest of code left out
}Its easy to get around by adding the namespace before the FromSqlRaw, e.g.
var query = RelationalQueryableExtensions.FromSqlRaw(context.MyEntities, "SELECT * FROM MyEntities");Include provider and version information
EF Core version: 6.0.0-rc.2.21480.5
Database provider: (various, Microsoft.EntityFrameworkCore.Sqlite)
Target framework: (e.g. .NET 6.0.rc2)
Operating system: Window
IDE: (e.g. Version 17.0.0 Preview 7.0)
Reactions are currently unavailable