Fluent NHibernate Cascade Issue - Trying To Insert NULL ID

前端 未结 3 1574
忘掉有多难
忘掉有多难 2021-01-02 00:40

I have the following models & mappings (code snippets further below).

One Competition has to have multiple CompetitionAnswers associated with it (multiple choice

3条回答
  •  庸人自扰
    2021-01-02 01:06

    References(x => x.Competition)
        .Column("CompetitionId")
        .Not.Nullable(); //add this
    

    and also make sure the child points to the parent in addition to the parent holding the child in it's collection. This is required when the parent is inverse.

    a1.Competition = c; 
    

    Was that column non null on database side but mapped as nullable on NH side?

提交回复
热议问题