Я не могу отобразить следующую структуру базы данных:
http://i.stack.imgur.com/iJmIq.png
Мне нужен логотип (LogoID - это UniqueKey) для одного носителя.Следуйте за моим беглым отображением:
public class SponsorMap : EntityTypeConfiguration<Sponsor>
{
public SponsorMap()
{
// Primary Key
this.HasKey(t => t.ID);
// Properties
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(255);
this.Property(t => t.Description)
.IsRequired();
this.Property(t => t.SiteAddress)
.HasMaxLength(300);
this.Property(t => t.TwitterName)
.HasMaxLength(20);
this.Property(t => t.FacebookAddress)
.HasMaxLength(300);
// Relationships
//this.HasOptional(t => t.Logo);
this.HasOptional(t => t.Logo)
.WithOptionalDependent();
}
}
Следуйте моделям:
public class Sponsor{
public Sponsor(){this.Goods = new List<Goods>();} public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string SiteAddress { get; set; }
public string TwitterName { get; set; }
public string FacebookAddress { get; set; }
public virtual ICollection<Goods> Goods { get; set; }
public virtual Media Logo { get; set; }
}
public class Media{
public Media(){}
public int ID { get; set; }
public string Path { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public virtual Goods Good { get; set; }
public virtual MediaType MediaType { get; set; }
}
Я получаю сообщение об ошибке в моем тесте:
Test method
Inove.Kenquer.Data.Tests.UserRepositoryTest.When_Save_User_With_Action_Get_Same_Actions_From_DB threw exception:
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: **Invalid column name 'Logo_ID'.**
-----------------------------------------
MediaMap has no mapping to Sponsor.
Как мне сопоставить его?