Stored Procedures and EF Code First

前端 未结 4 1930
谎友^
谎友^ 2021-02-14 02:23

I would like to use a stored procedure to retrieve entities from a DB, I don\'t care about tracking changes. I just need all entities be resolved including related ones.

<
4条回答
  •  醉酒成梦
    2021-02-14 02:47

    General answer about using stored procedures in EF is here so stored procedure in pure EF will not handle navigation properties. The answer also mentioned EFExtensions but that is not available in DbContext API.

    To execute stored procedure in DbContext API use:

    var entities = context.Database.SqlQuery(...);
    

    DbContext API doesn't offer any function import like EDMX and ObjectContext API.

提交回复
热议问题