How do I view the SQL generated by the Entity Framework?

后端 未结 22 2823
别那么骄傲
别那么骄傲 2020-11-21 05:35

How do I view the SQL generated by entity framework ?

(In my particular case I\'m using the mysql provider - if it matters)

22条回答
  •  温柔的废话
    2020-11-21 06:25

    If you are using a DbContext, you can do the following to get the SQL:

    var result = from i in myContext.appEntities
                 select new Model
                 {
                     field = i.stuff,
                 };
    var sql = result.ToString();
    

提交回复
热议问题