Foreign Keys

Posts   
 
    
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 07-Apr-2006 22:37:40   

Hi Why is this throwing a foreign key violation. I am using self servicing inside VS2K3 with SQL2K...

    Dim d As New DepartmentEntity(Guid.NewGuid)
    d.Name = "Information Technology"
    d.Save()

    Dim e As New EmployeeEntity(Guid.NewGuid)
    e.LastName = "Hill"
    e.FirstName = "Steven"
    e.Department = d
    e.Save()
bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 08-Apr-2006 03:12:37   

Is d a new entity or did it already exist? Can you post the sql trace for the code that you have listed. Look under the troubleshooting section of the manual for how to enable tracing.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 08-Apr-2006 12:12:16   

You've probably hidden the relation Department -> Employee. Unhide it and regenerate the code.

Frans Bouma | Lead developer LLBLGen Pro
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 10-Apr-2006 17:55:28   

Yes, indeed I hid it.

I guess I am confused. I hid the relation on Department because Department doesn't have an employee... Employee Has a Department. So I left the relationship on Employee.

I guess you are saying I need both?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Apr-2006 08:51:41   

Already answered in the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5845