This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I'm having a problem with the mapping between to tables both having composite keys. The error i get when trying to load the model configuration is this: Foreign key (FK8C35E6DA3F2FC42:AlternativeMember [Id])) must have same number of columns as the referenced primary key (AttributeMember [AttributeDefId, ObjectDefId]) I can't change the tables so i have to make this work. I have read about "Custom Association Resolver" but that seem to be only for LightSpeed not NHibernate Designer. The tables are created with this SQL code in the attached CreateTables.sql file. I have attached a screen dump of the data model and the properties for the association NHibernate Designer generates except that when the association is generated it does not get a backreference name. All examples i have found deal with one of the joined tables having a composite key not both. Se: http://stackoverflow.com/questions/6609840/problem-with-one-to-many-mapping-using-composite-keys Hopefully this information is enough to be able see what i am doing wrong. Thanks, Daniel The programs and versions i have: NHibernate Designer Version: 2.0.244.19740 Visual Studio 2010 with SP1 Database: SQL-Server 2008 Windows 7 Enterprise 64-bit |
|
|
Hi Daniel, Just to let you know, you're not doing anything wrong, this is a limitation in the designer. We're going to try to get an update out in the next couple of days -- if you're in a position to help beta test this then that would be great! |
|
|
I was able to get the mapping to work by changing “Mapping Representation” to FluentNHibernate and then altering the generated mapping code to use two column instead of the combined “Id”. The change was this (commented row was generated and my row is the one following it):
And the mapping class for table AttributeMember:
But I would still like to help you and test the beta version. |
|
|
Thanks for the update. We've now implemented this and it will be in the next nightly build. All you need to do is enter the composite key column names separated by commas into the Key Column Name setting e.g.
We will then generate suitable composite mappings in XML or Fluent NHibernate as required. The nightly build will be available from about 1200 GMT and you will be able to get it from the Downloads page. Let us know how it goes! |
|
|
I have now tested nightly build with my composite keys and it works if i use FluentNHibernate as mapping representation. But if i use the default (xml) i get this error: "Definition is not mapped [from Definition]". The error is thrown from the first call to NHibernate which is this line where Definition is a table in the model.
It seems like it could not load the mapping definition generated by NHibernate Designer. I have tested with nightly build's 20120221 and 20120223 and both had the same problem. |
|
|
Sorry you're still seeing problems with this. Would you be willing to share your model so we can try to figure out where the problem is occurring? You can attach a .nhmodel file using the Upload a File button. Thanks! |
|
|
Hi, I made a mistake when i tested with the default mapping representation. I had forgotten to change the code that created my ISessionFactory object. I was still using the FluentNHibernate version and of course that did not work when i wasn't using FluentNHibernate. So NHibernate Designer now works with my composite keys (if i use the right code to load the generated mapping). Thanks for all your help. |
|