Click here to Skip to main content
14,579,188 members
Rate this:
Please Sign up or sign in to vote.
Hello friends, I am currently migrating my project from ASP.Net to ASP.Net Core 3.x and have issues in retrieving data to my DTO(Data Transfer Object)

What I am doing currently is a data manipulation.
Following is what i tried with execute Raw SQL A-sync.

My ASP.Net code as well as ASP.Net Core code is provided below.

the only piece of code that is throwing an error is here.

What I have tried:

<pre> = _dbContext.Database.SqlQuery<sysmstatusgroup_dto>(sqlFinal).ToList();
Updated 22-Jun-20 6:57am
CHill60 22-Jun-20 4:23am
What is the error?
Azeezur 22-Jun-20 4:44am
.SqlQuery<sysmstatusgroup_dto>(sqlFinal). it is this part that is throwing the error
Maciej Los 22-Jun-20 5:30am
The qustion was: "what is the error" NOT "Where is the error"!
Azeezur 22-Jun-20 5:43am
OH sorry. I am not able to pass the data using SQL Query. is there another way that is recommended that i can use?
Maciej Los 22-Jun-20 5:53am
And the error message is...
Azeezur 22-Jun-20 5:57am
the error is as follows. (DatabaseFacade does not contain a definition for 'SQLQuery' and no accessible extension method 'SQLQuery' accepting a first argument of type 'DatabaseFacade' could be found.("are you missing a using directive or an assembly reference?"))

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can no longer execute SQL in that way in EF Core. See the discussion here[^] for alternatives. Further information at Executing Raw SQL Queries using Entity Framework Core | Learn Entity Framework Core[^]
Maciej Los 22-Jun-20 9:06am
CHill60 22-Jun-20 11:35am
Thank you Maciej

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100