Error while running Entity Framework Profiler

106 views
Skip to first unread message

vikram gharge

unread,
Jan 16, 2015, 7:29:11 AM1/16/15
to nhp...@googlegroups.com
Unable to cast object of type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection`1[MySql.Data.MySqlClient.MySqlClientFactory]' to type 'MySql.Data.MySqlClient.MySqlConnection'.

Oren Eini (Ayende Rahien)

unread,
Jan 16, 2015, 7:30:36 AM1/16/15
to nhprof
You need to call the EntityFrameworkAppender.Initialize() as the very first thing in your application

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


On Fri, Jan 16, 2015 at 2:29 PM, vikram gharge <vikram...@gmail.com> wrote:
Unable to cast object of type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection`1[MySql.Data.MySqlClient.MySqlClientFactory]' to type 'MySql.Data.MySqlClient.MySqlConnection'.

--
You received this message because you are subscribed to the Google Groups "nhprof" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhprof+un...@googlegroups.com.
To post to this group, send email to nhp...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhprof.
For more options, visit https://groups.google.com/d/optout.

vikram gharge

unread,
Jan 16, 2015, 7:32:38 AM1/16/15
to nhp...@googlegroups.com
Hey thanks for quick reply. I already called EntityFrameworkAppender.
Initialize() in my Application_Start event then also its giving same error.

Oren Eini (Ayende Rahien)

unread,
Jan 16, 2015, 7:46:12 AM1/16/15
to nhprof

Are you doing anything with EF before?
What is the full error?

--

vikram gharge

unread,
Jan 16, 2015, 8:15:02 AM1/16/15
to nhp...@googlegroups.com
As I am trying to write this given line EntityFrameworkAppender.Initialize();

I am getting error like 'HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkAppender' does not contain defination for 'Initialize'


On Friday, January 16, 2015 at 5:59:11 PM UTC+5:30, vikram gharge wrote:

Fitzchak Yitzchaki

unread,
Jan 18, 2015, 1:27:44 AM1/18/15
to nhp...@googlegroups.com
Can you make sure you have a reference for the appender dll of EFProf? 

Best Regards,

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Fitzchak Yitzchaki l Senior Software Engineer Mobile:+972-58-345-9538

--

vikram gharge

unread,
Feb 4, 2015, 5:04:28 AM2/4/15
to nhp...@googlegroups.com
Dear Friend,

I am getting below issue. I have made settings as per mentioned in your help. But when I am running my application, its giving me below error.

Unable to cast object of type 'HibernatingRhinos.Profiler.Appeder.ProfiledDataAccess.ProfiledConnection`1[MySql.Data.MySqlClient.MySqlClientFactory]' to type 'MySql.Data.MySqlClient.MySqlConnection'.

My application is in the MVC + Entity Framework. Database used for this application is MySQL.
 
Please help me for this issue. I am trying to find out solution for above problem since from last 3 weeks.

Thanks in advance


Oren Eini (Ayende Rahien)

unread,
Feb 4, 2015, 5:08:10 AM2/4/15
to nhprof
You are creating a MySQlConnection manually somewhere in your code, you cannot do that.
You have to go through the DbProviderFactory

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

vikram gharge

unread,
Feb 5, 2015, 4:46:16 AM2/5/15
to nhp...@googlegroups.com

Is below problem is because of entity framework version. I am using Entity Framework 4.5.2.

Below is the snipest of code where I am getting below issue.

 public ActionResult ProductStatisticalDataReport()
        {
            using (acc_dbEntities acdb = new acc_dbEntities())
            {

                var reportResult = acdb.pro_ProductStatisticalDataReport(); <= At this line below error is showing. This line reads procedure data and stores into the reportResult

                return View("ProductStatisticalDataReport", reportResult.ToList());

            }
        }

Unable to cast object of type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection`1[MySql.Data.MySqlClient.MySqlClientFactory]' to type 'MySql.Data.MySqlClient.MySqlConnection'.

Please help for this issue.

Fitzchak Yitzchaki

unread,
Feb 5, 2015, 5:01:19 AM2/5/15
to nhp...@googlegroups.com
Hello,

You should call the EntityFrameworkProfiler.Initialize() in the very beginning of your application. If you did this, than as Oren said, please make sure that you're not creating the connection directly, but using the DbConnection frmo the connection factory.

You can send us a sample application that repro your issue and we'll analyze the exact issue in your case.

Best Regards,

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Fitzchak Yitzchaki l Senior Software Engineer Mobile:+972-58-345-9538

Reply all
Reply to author
Forward
0 new messages