NHibernate - Mapping a String Foreign Key

后端 未结 4 441
天涯浪人
天涯浪人 2021-01-19 12:48

The legacy database I\'ve inherited contains the following tables:

Teams ( 
 TeamId INT PRIMARY KEY,
 Name VARCHAR(30)
)

Players (
 PlayerId INT PRIMARY KEY         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-01-19 13:15

    Now I'm not 100% sure if this will work but have you tried a many-to-one mapping relationship?

    Maybe something like this:

    
    

    I believe that should work, according to the NHibernate manual property-ref is an attribute that is useed for mapping legacy data where a foreign key refers to a unique key of the associated table other than the primary key. This sounds like the situation you find yourself in.

提交回复
热议问题