With Entity Framework Core removing dbData.Database.SqlQuery
I can\'t find a solution to build a raw SQL Query for my full-text search query th
In EF Core you no longer can execute "free" raw sql. You are required to define a POCO class and a DbSet
for that class.
In your case you will need to define Rank:
var ranks = DbContext.Ranks
.FromSql("SQL_SCRIPT OR STORED_PROCEDURE @p0,@p1,...etc", parameters)
.AsNoTracking().ToList();
As it will be surely readonly it will be useful to include the .AsNoTracking()
call.
EDIT - Breaking change in EF Core 3.0:
DbQuery() is now obsolete, instead DbSet() should be used (again). If you have a keyless entity, i.e. it don't require primary key, you can use HasNoKey() method:
ModelBuilder.Entity().HasNoKey()
More information can be found here