Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compound natural key in DbSet.AddOrUpdate

I'm trying to use the CodeFirst data migrations in EF5 with a table that has a composite natural key. Is it possible to specify this in the first argument to DbSet.AddOrUpdate, like

context.Table1.AddOrUpdate(
     t=>t.Column1 && t.Column2,
     new Table1 { properties... }
);

How would one specify using more than one property in this case?

Thanks, Matthew

like image 468
Matthew Belk Avatar asked Oct 09 '12 21:10

Matthew Belk


1 Answers

Turns out I had to use an anonymous type in the first argument, e.g.

t => new { t.Column1, t.Column2 }
like image 199
Matthew Belk Avatar answered Oct 22 '22 03:10

Matthew Belk