Reputation: 150238
I'm trying to start using EF Migrations with an existing database.
The startup project is an MVC 3 project and the domain objects are in a separate project of the same solution.
Here are the steps I took:
Add-Migration InitialMigration -IgnoreChanges -Verbose
Created Configuration.cs and ###_InitialMigration.cs. Had to edit Configuration.cs to add the name of my context object as it is in a separate project.
Update-Database
Added dbo.__MigrationHistory to my database
Added a new property to an existing class
private ulong? myProp;
[DataMember]
public ulong? MyProp
{
get { return myProp; }
set
{
if (myProp != value)
{
myProp = value;
RaisePropertyChanged(() => this.MyProp);
}
}
}
Successfully compiled the solution.
Add-Migration MyNewMigration
Created ###_MyNewMigration.cs, with no migrations in it:
public partial class MyNewMigration : DbMigration
{
public override void Up()
{
}
public override void Down()
{
}
}
Not looking good... where are the migrations?
Update-Database -Verbose -Script
No mention of the new property in the upgrade script
INSERT INTO [__MigrationHistory] ([MigrationId], [CreatedOn], [Model], [ProductVersion]) VALUES ('201206122137444_MyNewMigration', '2012-06-12T22:07:49.170Z', 0x1F8B080YadaYada, '4.3.1')
How can I get EF Migrations to pick up the model change?
Upvotes: 2
Views: 1732
Reputation: 150238
It turns out that EF Migrations does not like the ulong?
data type I used. That property was ignored without any warning.
Changing the type to long?
allowed the migration to succeed.
Upvotes: 3