EF Core execute sql

孤者浪人 提交于 2020-01-03 13:35:26

问题


Am testing out Entity Framework Core, it's been well so far until i hit an error. I am not able to execute sql from a DbSet with FromSql. Error is dbset does not contain a definition for 'FromSql' The code is

_context.Account.FromSql("Select * from dbo.Account");

What am i doing wrong?


回答1:


It happened that I needed one more nuget package to get FromSql as well as Include to work. I added this to my dependencies in the project.json file and after the restore, Voila.

"Microsoft.EntityFrameworkCore.Relational": "1.0.0"

Works now




回答2:


Please add namespace

using Microsoft.EntityFrameworkCore;


来源:https://stackoverflow.com/questions/38909553/ef-core-execute-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!