Click here to Skip to main content
15,886,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I want to map this SQL table, named Media, using EF 5.0 CodeFirst, through DataAnnotations or Fluent.
[MediaID] INT NOT NULL PRIMARY KEY,
[Name] VARCHAR(100) NOT NULL,
[ArtistID] INT NOT NULL,
[ReleaseDate] DATE NULL,
[Rating] INT NULL,
[Price] FLOAT NOT NULL,
[AlbumID] INT NULL


to these classes:

C#
public class Media
{
    public virtual int MediaId { get; set; }
    public virtual string Name { get; set; }
    [ForeignKey("ArtistId")]
    public virtual Artist Artist { get; set; }
    public virtual DateTime ReleaseDate { get; set; }
    public virtual int Rating { get; set; }
    public virtual float Price { get; set; }

    public virtual IList<Genre> Genres { get; set; }
    public virtual IList<CustomerReview> CustomerReviews { get; set; }
}

public class Album : Media
{
    public virtual IList<Song> Songs { get; set; }
}

public class Song : Media
{
    public virtual Album Album { get; set; }
}


Thanks in advance, to anyone who can help me :)
Posted
Updated 29-Oct-13 12:13pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900