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
|
We have a very large database with lots of inner-table relationships. The problem arrises when we have a multi-column relationship between two tables, the tool is creating two virtual relationships with the same name. Nhibernate is saying that this is a duplicate collection, which is causing validation and compile errors. This is happening repeatedly, upto 10 times for 1 table, and over 300 times in our schema.
An example:
private IList<BAssetDep> _bAssetDeps = new List<BAssetDep>();
public virtual IList<BAssetDep> BAssetDeps{
get { return _bAssetDeps; }
set { _bAssetDeps = value; } }
private IList<BAssetDep> _bAssetDeps = new List<BAssetDep>();
public virtual IList<BAssetDep> BAssetDeps{
get { return _bAssetDeps; }
set { _bAssetDeps = value; } } And the XML: <bag name='BAssetDeps' inverse='true'> <key column='`DEP_ASSET_ID`' /> <one-to-many class='BAssetDep' /> </bag> <bag name='BAssetDeps' inverse='true'> <key column='`SPT_ASSET_ID`' /> <one-to-many class='BAssetDep' /> </bag>
Any help would be appreciated
Any help would be appreciated
Any help would be appreciated
Any help would be appreciated
|
|
|
The designer is using the plural of the target entity as its "best guess" for the collection name. If you have multiple associations to the same entity type, the designer can't make a better guess. We considered adding a disambiguation suffix, e.g. BAssetDeps1 and BAssetDeps2: this would of course make the errors go away, but when you came to use one of the associations in your code, you would have no idea whether to use 1 or 2. So we opted to make the designer warn so that you could assign meaningful names instead (which you can do by selecting the association arrow and editing the Collection Name in the properties window). We're definitely open to suggestions on how we could avoid this problem -- how we could create unambiguous names -- without leaving you with meaningless Xxx1 / Xxx2 names. Perhaps BAssetDepsByDepAsset / BAssetDepsBySptAsset -- would something like that make sense? What names would you ideally like to see generated? |
|
|
Actually the BAssetDepsByDepAsset and BAssetDepsBySptAsset would make the most sense in our case, since it also gives additional information about the relationship. |
|
|
I've made an update to disambiguate duplicates this way when you drag tables on from Server Explorer. Note this will only happen if the duplicate names are inferred at the same time -- it won't happen if one association already exists and you then create another in the database and do an Update Model From Database -- but it should kick in for the initial table drag which is causing you grief. The updated build should be in the Visual Studio gallery now, so if you installed from there you should be able to get it from Tools > Extension Manager > Updates tab (note it can take a while to find updates!). Let us know if it meets your requirements! |
|
|
That worked great. Thank you for the quick response. |
|