views:

158

answers:

0

I have three classes-- User, Team, and ProjectBid. Both User and Team inherit from a IProjectBidder interface. I want to map them in ActiveRecord something like this:

class Team: ModelBase<Team>, IProjectBidder
{
        [HasMany(typeof(ProjectBid), Table = "ProjectBid", ColumnKey = "BidderID", Lazy     = true)]
        public IList<ProjectBid> ProjectBids{get;set;}
}

class User: ModelBase<User>, IProjectBidder
{
        [HasMany(typeof(ProjectBid), Table = "ProjectBid", ColumnKey = "BidderID", Lazy = true)]
        public IList<ProjectBid> ProjectBids{get;set;}
}

class ProjectBid : ModelBase<ProjectBid>
{
        [Any(typeof(int), MetaType = typeof(string), TypeColumn = "BidderType", IdColumn = "BidderID", Cascade = CascadeEnum.None)]
        [Any.MetaValue("USER", typeof(User))]
        [Any.MetaValue("TEAM", typeof(Team))]
        public IProjectBidder Bidder { get; set; }
}

But when it creates this schema in the database, it's adding a "Key" to the ProjectBid table-- that the BidderID column must contain a Team ID. Why is it creating this constraint?