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.refauthrequests.Add(refauthEntity);
_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
};
_db.SaveChanges();
If you set debugger you will see the output window
Comments
Post a Comment