How can I log the generated SQL from DbContext.SaveChanges() in my Program? [duplicate]

In entity framework 6.0, the Database class has a property Action<string> Log. so setting up logging is as easy as:

context.Database.Log = Console.WriteLine;

For more advanced needs you can set up an interceptor.

Leave a Comment