I´m working with MVC3 in ASP .NET and stuck a little at the databasemodel.
I use the EntityFramework to create tables from my models. Now I want to define a PrimaryKey that depends from the MaterialID and the ListID. But how can I define it in C#?
Is there a Tag like [Key] to define that the PrimaryKey depends on more than one value?
If you're using Entity Framework 4, you can specify a composite key in the constructor of your entity configuration like so:
HasKey(m => { m.MaterialID, m.ListID });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.