开发者

How to map a Many-To-Many with CodeFirst and Membershipservice

i started a little learning project a week ago and i cant seem to find an answer to my question.

I use EF Codefirst CTP5 to build my classes. It worked very will till now :)

I have a class that is called "cup".

Which looks like the following:

public class Cup
{
    public int ID { get; set; }

    [Required(ErrorMessage = "Title is required")]
    [StringLength(160)]
    public string Title { get; set; }

    [Required(ErrorMessage = "Startdate is required use Format: DD.MM.YYYY HH:MM")]
    public DateTime StartDate { get; set; }

    [Required(ErrorMessage = "Checkindate is required use Format: DD.MM.YYYY HH:MM")]
    public DateTime CheckInDate { get; set; }

    [Required(ErrorMessage = "Please specifiy the maximal playercount.")]
    [Range(10, 100, ErrorMessage = "The maximal playercount must be between 10 and 100")]
    public int maxAttendees { get; set; }

    [Key] 
    public virtual MembershipUser owner { get; set; }
    [Key] 
    public virtual开发者_Python百科 ICollection<MembershipUser> registredUser { get; set; } 
}

The idea is that i want the users to be able to register to that cup. So i need many to many relation between cup and my users table.

Thats where the problem starts. I use the integrated MembershipService ( which is the one the wizards add you aka AccountModel.cs ). I exported the table to my database and everything works in regard to authentication. I cant figure out how to tell the cup model to create a connection to the users table.

The rule is: One cup can have many users One user can be in many cups One user is the owner many cupy

How to solve this ?

Thanks in advance

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜