How to execute SqlQuery with Entity Framework Core 2.1?

前端 未结 2 1122
暖寄归人
暖寄归人 2020-12-29 07:04

In Entity Framework 6, I can execute a raw SQL query on the database using the following command:

IEnumerable Contact.Database.SqlQuery

        
2条回答
  •  感情败类
    2020-12-29 07:41

    You can use ExecuteSqlCommandAsync method which is defined in RelationalDatabaseFacadeExtensions class of Microsoft.EntityFrameworkCore.Relational assembly by the following way.

    _databaseContext.Database.ExecuteSqlCommandAsync()
    

提交回复
热议问题