I installed MiniProfiler and MiniProfiler.EF in my project via nuget.
Before using MiniProfiler, I would open the connection using this in my model repository:
public class NotificationRepository { private CBNotificationModel.CB_NotificationEntities db; public NotificationRepository() { db = new CB_NotificationEntities(); } public NotificationContact GetNotificationContacts() { return db.NotificationContacts.ToList(); } }
To use the mini profiler, I created:
public static class ConnectionHelper { public static CB_NotificationEntities GetEntityConnection() { var conn = new StackExchange.Profiling.Data.EFProfiledDbConnection(GetConnection(), MiniProfiler.Current); return ObjectContextUtils.CreateObjectContext<CB_NotificationEntities>(conn);
The model repository now uses
db = ConnectionHelper.GetEntityConnection();
However, this gives an error:
An unhandled exception of type "System.StackOverflowException" occurred in the mscorlib.dll file
Did I miss a step? I tried to add MiniProfilerEF.Initialize () and MiniProfilerEF.Initialize_EF42 () to Application_start (), but that will just change the errors given.
It seems that there is not much information about setting up an entity framework project to use miniprofiler if it is not code.
Ryan sampson
source share