Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Insights bug when updating database

I have recently installed application insights to my ASP.Net MVC 5 project, and it works as intended.

But when I run Update-Database command to apply my migrations to database I get the following error: Couldn't find type for class Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener.

The project on which I run Update-Database is separate project ( class library ) which is included into web project.

Anyone knows how to fix this?

UPDATE: It works when I uninstall ApplicationInsightsTraceListener nuget package, but it would be good if it can be fixed without uninstalling it.

like image 494
Aleksa Avatar asked Oct 30 '22 07:10

Aleksa


1 Answers

When you run the migrations the entry point is the DbContext. It looks like you've not added the NuGet package for the ApplicationInsightsTraceListener to your Data Layer. Usually you only add the ApplicationInsights NuGet packages to the Web App and potentially your Console Applications/Web Jobs.

To get around this without installing the NuGet packages you can remove your Trace code from your DbContexts, also remember to remove them from the classes that your DbContexts relies upon. ..or just install the correct NuGet packages in the Data Layer too.

Regards..

like image 181
Molibar Avatar answered Nov 11 '22 13:11

Molibar