In meiner Klasse produc
habe ich eine Sammlung von Fotos. Eines der Fotos in dieser Sammlung stellt das Hauptproduktfoto dar.Objektnavigation Referenz in EF
Meine Klasse von Produkten
public class Product
{
public Guid ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public virtual ICollection<Photo> Photos { get; set; }
public virtual Photo Photo { get; set; }
}
Die Eigenschaft photo
muss ein Foto in der Fotosammlung zeigen.
ProducsConfiguration
das Schema der Datenbank zu erstellen, verwenden Sie die folgende Konfiguration:
public class ProductConfiguration : EntityTypeConfiguration<Product>
{
public ProductConfiguration()
{
HasKey(p => p.ID)
.Property(p => p.ID)
.IsRequired();
Property(p => p.Name)
.IsRequired()
.HasMaxLength(65);
HasMany(p => p.Photos).WithMany().Map(m => m.ToTable("ProductPhotos"));
...???...
}
}
Frage
Wie würde die Konfiguration (FLUENT Konfiguration EF verwenden) für in Bezug auf die Eigenschaft photos
als Verweis auf eines der Fotos in der Sammlung Photos
??
Danke!