Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 5 expects CreatedOn column from MigrationHistory table

Tags:

I am migrating an MVC 3 application from EF 4.3 to EF 5. I noticed that EF 5 expects a CreatedOn column in the __MigrationHistory table, which does not exist as the migrations were created by an older version.

SELECT TOP (1) 
[c].[CreatedOn] AS [CreatedOn]
FROM [dbo].[__MigrationHistory] AS [c]

How do I resolve this issue without wiping my migration history? I am thinking of a query to infer the column's value from the migration name, which is in the following format:

201203111201542_MigrationName
like image 271
CMircea Avatar asked Aug 16 '12 00:08

CMircea


2 Answers

The CreatedOn column is no longer required. We attempt to query from it in order to determine whether we need to drop it. i.e. You are upgrading from 4.3 to 5.

like image 121
Andrew Peters Avatar answered Sep 28 '22 09:09

Andrew Peters


Just like Filip Cornelissen said, it is a thing between MiniProfiler.EF and Entity Framework 5.0.

Solving/hiding the problem is actually easier than you would think. It is only a "debugging problem" as the error you'll get is only happening during the instantiating period (checking for new migrations), and the error is an "SQL Unhandeld Exception".

So, solving this problem is easy:

Go in Visual Studio to your "DEBUG" tab. Hit the "Exceptions" item. In the new dialog, you open the tree "Common Language Runtime Exceptions". Under "System.Data.SqlClient, uncheck both checkboxes after "System.Data.SqlClient.SqlException". Add it, if it ain't there.

And off ya go!

like image 20
s.meijer Avatar answered Sep 28 '22 10:09

s.meijer