c# - Mapping JoinedSubclassMapping -


i'm getting error when try insert purchasecredit:

sql logic error or missing database foreign key mismatch - "purchasecredit" referencing "deposit"

this part of generated sql:

create table financialdeposit  (     id  integer primary key autoincrement,     version bigint not null,     datepayment date,     total money,     status int, )  create table deposit  (     financialdepositid bigint not null unique,     accountid bigint not null,     personname varchar(250) not null,     primary key (financialdepositid),     constraint fk737cdd9090887321 foreign key (accountid) references account,     constraint financialdepositfk foreign key (financialdepositid) references financialdeposit )  create table purchasecredit  (     id  integer primary key autoincrement,     version bigint not null,     purchasecode uniqueidentifier not null unique,     depositid bigint,     total money,     constraint fk737cdb4bfa0e8716 foreign key (depositid) references deposit ) 

and part of c# code:

public class financialdepositmap : classmapping<financialdeposit> {     public financialdepositmap()     {         property(x => x.datepayment, map => map.column(a => a.sqltype("date")));         property(x => x.total);         property(x => x.status);         property(x => x.datepayment);         property(x => x.hash);     } }  public class depositmap : joinedsubclassmapping<deposit> {     public depositmap()     {         manytoone(x => x.accountid, m => m.notnullable(true));         property(x => x.personname, m => m.notnullable(true));     } }  public class purchasecreditmap : classmapping<purchasecredit> {     public purchasecreditmap()     {         property(x => x.purchasecode, map =>         {             map.unique(true);             map.notnullable(true);             map.update(false);         });          manytoone(x => x.deposit);         property(x => x.total);     } } 

how can map column "deposit" "purchasecreditmap" sql:

create table purchasecredit  (     ...     constraint fk737cdb4bfa0e8716 foreign key (depositid) references deposit (financialdepositid) ) 

you don't have keys or ids defined in mappings.

see here inheritance mappings in mapping-by-code


Comments