Thursday, August 10, 2017

How to view the SQL generated query by the Entity Framework

If we want to write log file of Entity Framework query in EF 6 we can follow this step

Step 1: Open EDMX cs file and copy the code:

  protected override void OnModelCreating(DbModelBuilder modelBuilder)  
       Database.Log = (query) => Debug.Write(query);  

Step 2 : write log on your Entity Framework query

  refauthrequests refauthEntity = EM_Refauthrequests.ConvertToEntity(vsspoAuditModel);  
       _db.Database.Log = queryLog =>  
         Debug.Print(queryLog); // Debug.Print will show the output on visual studio output window You can write log using queryLog value  

If you set debugger you will see the output window

vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.