views:

12

answers:

0

I am using trunk version of FluentNHibernate (AutoMapping) with SQL Server 2008. In my code the class User references two instances of class PublicationsList, it looks like this:

public class User : EntityBase
{
    public virtual PublicationsList Booklog { get; private set; }
    public virtual PublicationsList Library { get; private set; }
}

but when I try to save a User instance, SQL Server produces error:

Could not execute command: UPDATE [User] SET /* blah, blah*/ WHERE Id = @p7
System.Data.SqlClient.SqlException (0x80131904): The UPDATE statement conflicted 
with the FOREIGN KEY constraint "FK7185C17CFF70E43". The conflict occurred in 
database "tests", table "dbo.PublicationsList", column 'Id'.

so it seems that FluentNHibernate creates constraints incorrectly in this case. Is there any work around?

related questions