I am re-writing an app that sits over a legacy database. I'm using NHibernate and I've had problems getting some mappings to work and would like some help.
First, the table structure:
Tech: Id FirstName LastName
User: TechID Username
The "User" table has no primary key. Foreign keys are no enforced at all. TechId is support to correspond to the Id on the Tech table.
My classes in memory are:
Tech: Id FirstName LastName User (type: User)
User: Id Username
The tables and objects will always be 1-1.
At first I tried a HasOne relationship in the mappings but everytime it tried to save it did an update instead of an insert and when creating a new record I would get the infamous "update count expect: 1, actual:0 " type message.
I am also fine with changing my model so the Username is directly on the Tech but I can't get that mapping to work either.
Any suggestions are greatly appreciated.
Thanks
|