Я пытаюсь создать быстрое приложение ASP.NET MVC 3 с использованием RC версии EF 4.1. У меня две модели:
public class Race
{
public int RaceId { get; set; }
public string RaceName { get; set; }
public string RaceDescription { get; set; }
public DateTime? RaceDate { get; set; }
public decimal? Budget { get; set; }
public Guid? UserId { get; set; }
public int? AddressId { get; set; }
public virtual Address Address { get; set; }
}
и
public class Address
{
public int AddressId { get; set; }
public string Street { get; set; }
public string StreetCont { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public virtual Race Race { get; set; }
}
При попытке вставить новую расу я получаю следующую ошибку:
Невозможно определить главный конец связи между типами 'rcommander.Models.Race' и 'Rcommander.Models.Address. основной конец этой ассоциации должен быть явно сконфигурирована с использованием свободно распространяемый API или данные аннотации.
Не следует ли автоматически распознавать RaceId в качестве первичного ключа таблицы Races и AddressId как FK в таблице адресов? Я что-то пропустил?
Спасибо!