I have two tables that are built using codefirst entity framework.
public class TimeEntry:Entity
{
[Required]
[Display(Name = "Activity")]
public int ActivityId { get; set; }
public virtual Activity Activity { get; set; }
}
public class Activity:Entity
{
private ICollection<TimeEntry> _timeEntries;
[Required]
public string Description { get; set; }
public virtual ICollection<TimeEntry> TimeEntries
{
get
{
return _timeEntries ?? (_timeEntries = new List<TimeEntry>());
}
set
{
_timeEntries = value;
}
}
}
public class Entity
{
public int Id { get; set; }
}
These are the classes I have created for my Db. There is no problem with creating the database. When I try to perform CRUD operations I get the error
DataBinding: 'System.Data.Entity.DynamicProxies.Activity_AD12BF558F098271F1F51B3B1489B4B3B281FD0B686C8457333DE5BEE0E8B6A9' does not contain a property with the name 'ActivityId'
It is trying to find ActivityId in the Activity table however the primary key is Id. How do I map the foreign key ActivityId in the TimeEntry table to the primary key Id in the Activity table.