GithubHelp home page GithubHelp logo

Comments (16)

yellis avatar yellis commented on July 16, 2024

What were you doing when you got this message? Are you saving results to Sql?

from dotnet.

Yustie avatar Yustie commented on July 16, 2024

I'm starting my web application and than It breaks with that exception when its still loading the browser.
I'm guessing that miniprofiler expects a column createdOn, while there isn't any.

from dotnet.

yellis avatar yellis commented on July 16, 2024

CreatedOn does not appear in the MiniProfiler code base.

My guess is that your Entity Framework data context has a CreatedOn column in some table and your database does not, and the MiniProfilerEF.Initialize() function is causing an error to occur because of this.

Do you have CreatedOn anywhere in your data context?

from dotnet.

Yustie avatar Yustie commented on July 16, 2024

CreatedOn used to be a column in version 4.xx (or something) in EF. As of version 5 that was no longer the case. I'm at 6 and there is no such column in any of my models or the migrationhistory table.

from dotnet.

yellis avatar yellis commented on July 16, 2024

Well, it's coming from somewhere in your code (it definitely isn't from MiniProfiler).

from dotnet.

Yustie avatar Yustie commented on July 16, 2024

Check the first comment on this post: http://stackoverflow.com/questions/11979026/entity-framework-5-expects-createdon-column-from-migrationhistory-table
Do you have access to the link in that first comment? It's either deleted or private. But related to this issue.

from dotnet.

yellis avatar yellis commented on July 16, 2024

It points here

from dotnet.

oleneveu avatar oleneveu commented on July 16, 2024

I'm experiencing exactly the same problem (.ef6 3.0.10-beta5, .net 4.0)
It happens when initializing my dbcontext in Application_Start().
If I remove MiniProfilerEF6.Initialize(), everything works fine. If I add the column CreatedOn to the __MigrationHistory table, it works once. Next time the column has been removed by EF and the exception throws again...

from dotnet.

Yustie avatar Yustie commented on July 16, 2024

@oleneveu, yellis is pretty hardheaded, I don't think he will look into it. He's very convinced it's our code. Also, he closes issues instantly.

Try this post on SO: http://stackoverflow.com/questions/23587321/miniprofiler-breaks-on-missing-createdon-column

from dotnet.

yellis avatar yellis commented on July 16, 2024

Can either of you give code (preferably a full solution zipped or pushed to a rep - even better if you can reproduce this in a fork of Sample.Mvc) that can be used to replicate this?

I believe you that it is happening but cannot reproduce it.

from dotnet.

oleneveu avatar oleneveu commented on July 16, 2024

I have provided some information on the SO post. I will try to provide a project to reproduce the problem if I have enough time...

from dotnet.

yellis avatar yellis commented on July 16, 2024

To clarify - is this only happening when you run in VS in debug mode? Does it show up in non-debug mode or on prod?

All of the solutions that I have seen revolve around either adding a CreatedOn column to __MigrationHistory, turning off change tracking or not throwing this exception in the debugger. Well how about we just swallow this exception in MiniProfilerEF6.Initialize() - the same way that we are doing right now for a similar error with column "ContextKey"?

This error itself seems to be pretty innocuous and is indicative of some weird leftover issue from EF 4.3 >> EF 5 that is triggered by the way we are tapping into EF6 here, so just ignoring the error doesn't seem like it will cause any harm.

Thoughts?

from dotnet.

oleneveu avatar oleneveu commented on July 16, 2024

I can provide a sample project to reproduce the problem. You can download the zip here:
http://peuplier.i234.me:80/fbsharing/1NRKeqDK
I have removed all binaries, you will have to restore nuget packages.
It seems that EF migrations have to be enabled for the problem to occur. This sample uses SqlCE 4, it might also be related to it...

The break occurs in Application_Start() (see the comment).

from dotnet.

oleneveu avatar oleneveu commented on July 16, 2024

You are right, this is not a real error but just a break that occurs for a reason that I could not find. I have spent some time searching for the code that could be in cause (System.Diagnostics.Debugger.Break();?) without success.
When running outside of the debugger, everything works fine...

from dotnet.

yellis avatar yellis commented on July 16, 2024

Ok, I am able to replicate it. This does correspond to the section of code that @oleneveu posted on SO. The EF code here is designed to try out a legacy migration method, and if it catches an error it doesn't do anything with it (the whole purpose of doing this is to see if a CreatedOn column exists, and if so, to drop it first). As others have said, you can avoid this by manually creating a CreatedOn column but this will be dropped every time, so that is not so practical.

The issue itself is within the EntityFramework code, where (I believe) they are catching an EntityException when trying out this code. When this is accessed through EntityFramework without MiniProfiler, it catches the EntityException, because the __MigrationHistory table is being accessed through Entity Framework. However, when MP intercepts this command and runs it through a ProfiledDbCommand, it throws a DbException when it fails, not an EntityException, and if you are set to catch these (as you are by default) in debug mode, then you know what happens.

Potential solutions:

  1. Submit a PR to EntityFramework to add catch (DbException) {} to this section of code
  2. Ignore the Exception using the solution given by @oleneveu in his SO answer.
  3. Don't use EF Migrations

I just spent some time trying to trap and catch the exception in different ways within the MP.EF6 code, and each time the user-unhandled exception from EntityFramework was still caught and thrown by Visual Studio (until doing option 2 above).

At this point, since it is a debug-only issue and I do not have a way to prevent it from happening in EF6 using our method of initializing MiniProfiler for EF6, I do not see any code changes happening in the MP.EF6 code to address this issue, and the potential solutions above are my recommendations for how to proceed if this issue is occurring for you.

from dotnet.

oleneveu avatar oleneveu commented on July 16, 2024

I think that the problem may be related to the fact that the PDB files are included in the NuGet packages. I have noticed that if I remove the MiniProfiler PDB files, the break does not occurs anymore.
I have edited my SO answer to provide another workaround.

from dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.