tags:

views:

1

answers:

0

Hi

I am trying to evaluate SubSonic using SimpleRepository, I have come across a problem with the auto migrations however and I am wondering what the suggested solution is. Lets say we have a table called something like

public class Member
{
   [ScaffoldColumn(false)]
public Guid ID { get; set; }

    public string FirstName { get; set; }

    [SubSonicNullString]
    public string LastName { get; set; }


    public string EmailAddress { get; set; }

    [SubSonicNullString]
    public string MobileNumber { get; set; }

public Member()
{
    this.ID = Guid.NewGuid();
}

}

and we have already added a few of these into the database. Now we want to add a foreign key to the Club so we add

public class Club
{
    public Club()
{
    this.ID = Guid.NewGuid();
}
    public string Name { get; set; }
}

and the below to Member

public Club ClubAffiliation { get; set; }
   public Guid ClubID { get; set; }

The example is a little contrived but it demonstrates the point (something more realistic may be a MemberStatus). When we call the migration sql understandably gets angry at you, you cant add the column as its not nullable, and you cant foreign link it as there are no clubs. What I would normally do is run some sql to make sure Club is added first put in a club and and make that the default. I was looking at ways to achieve this with SubSonic and came across extending from Migration but that doesnt even seem to exist anymore in 3.

How are you suppossed to deal with this type of situation with the SimpleRepository?