Using the Entity Framework tools I reverse engineered code first the POCO classes for a MySQL database into a class library. I created an MVC project that references this class library and I am trying to create a controller with read/write actions and views. After setting the model and data context classes and clicking "Add" I get this error:
EntityType xxx has no key defined. Define the key for this EntityType.
The problem is, in the map it is marked properly:
public UserApplicationMap()
{
// Primary Key
this.HasKey(t => new { t.UserID, t.AppID });
...
I tried doing this in the class:
public class UserApplication
{
[Key, Column(Order = 0)]
public int UserID { get; set; }
[Key, Column(Order = 1)]
public int AppID { get; set; }
But the compiler had a fit with the Column attribute and flagged it as invalid.
So I am a bit stumped. I really don't want to add an auto increment field to this table if I can just use a composite key.
I am using Visual Studio 2012, EF 5, MVC 4, and MySQL connector 6.6.4