I need to add a new column (MyNewField for example of type Int) to a table and change the existing primary key (i.e. UserId for example) to be a combination of both the UserId and MyNewField via Entity Framework.

That part is easy:

this.HasKey(t => new { t.UserId, t.MyNewField });

But I already have data in this table which only relied on the UserId primary key, so this is likely to cause an error when I do this.

Is there a way for me to insert a value (same one will do for now) before this is turned into a primary key combining both fields?

Note that the above EF statement is part of a class that inherits from: EntityTypeConfiguration



0 Answers