Post your entire mapping assembly setup with conventions somewhere, maybe upload a .zip to dropbox or send your code to github and I'll take a look when I have time.
On Wed, May 22, 2013 at 1:23 PM, Riderman Sousa <riderma...@bindsolution.com > wrote: > I'll stick with the IAutoMappingOverride :) > > Any tips on this error? Only occurs if I set the interface > IAutoMappingOverride > > public class CompanyConvention : IAutoMappingOverride<Company> > { > public void Override(AutoMapping<Company> mapping) > { > mapping.HasManyToMany(a => > a.Persons).Cascade.AllDeleteOrphan().Not.Inverse(); > } > } > > > > > > On Wed, May 22, 2013 at 2:17 PM, Carl Bussema <carl.buss...@gmail.com>wrote: > >> Yes, but you'll still need to use a map to mark one end inverse. I don't >> recall how nh operates without that detail. Also use iset or Icollection >> unless you need to maintain order (1 st 2 nd etc) >> On May 22, 2013 12:49 PM, "Riderman Sousa" <riderma...@bindsolution.com> >> wrote: >> >>> When I do this, I get the following error: >>> >>> `There is already an object named 'Company' in the database. ---> >>> System.Data.SqlClient.SqlException: There is already an object named ' >>> Company' in the database.` >>> >>> >>> If not using IAutoMappingOverride what do you recommend? >>> Create an IList in Person? Like `IList<Company> Companies` >>> >>> >>> >>> On Wed, May 22, 2013 at 1:08 PM, Carl Bussema <carl.buss...@gmail.com>wrote: >>> >>>> That post looks complicated, and I'm still not convinced it's a good >>>> idea, but if you can't get it working, use a simpler method. >>>> >>>> Define an override class: >>>> >>>> public class CompanyMapOverrides : IAutoMappingOverride<Company> >>>> { >>>> public void Override(FluentNHibernate.Automapping.AutoMapping<Company> >>>> mapping) >>>> { >>>> mapping.HasManyToMany(a => >>>> a.Person).Cascade.AllDeleteOrphan().Not.Inverse(); >>>> } >>>> >>>> } >>>> >>>> Make sure you include the override in your mapping: >>>> mappings.UseOverridesFromAssemblyOf<CompanyMapOverride>(); >>>> >>>> >>>> Alter Cascade requirements to suit. You can get conventions to declare >>>> the table name: >>>> >>>> using FluentNHibernate.Conventions.Inspections; >>>> using inflector_extension; >>>> using FNH = FluentNHibernate; >>>> >>>> >>>> public class ManyToManyTableNameConvention : >>>> FNH.Conventions.ManyToManyTableNameConvention >>>> { >>>> protected override string >>>> GetBiDirectionalTableName(IManyToManyCollectionInspector collection, >>>> IManyToManyCollectionInspector otherSide) >>>> { >>>> >>>> return collection.EntityType.Name.InflectTo().Pluralized + >>>> "_" + >>>> otherSide.EntityType.Name.InflectTo().Pluralized; >>>> } >>>> >>>> protected override string >>>> GetUniDirectionalTableName(IManyToManyCollectionInspector collection) >>>> { >>>> return collection.EntityType.Name.InflectTo().Pluralized + >>>> "_" + >>>> collection.ChildType.Name.InflectTo().Pluralized; >>>> } >>>> } >>>> >>>> >>>> >>>> >>>> On Wed, May 22, 2013 at 11:54 AM, Riderman Sousa < >>>> riderma...@bindsolution.com> wrote: >>>> >>>>> And if I use some attribute to map this kind of relationship? >>>>> >>>>> *like:* >>>>> class Company >>>>> string Name >>>>> [ManyToMany(TableName="PersonCompany"]) >>>>> IList<Person> Persons >>>>> >>>>> I see it in this >>>>> post<http://stackoverflow.com/questions/6822430/fluent-nhibernate-mapping-hasmanytomany-by-convention/12198533#12198533>, >>>>> but I failed to implement. >>>>> >>>>> I need a way (convention or not) to perform this task. >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, May 22, 2013 at 10:51 AM, Carl Bussema <carl.buss...@gmail.com >>>>> > wrote: >>>>> >>>>>> I don't think you can. You either need a bidirectional association or >>>>>> a classmap or an override. I wouldn't want to have a convention deciding >>>>>> which relationships were 1:N and which where N:M... you can read it from >>>>>> the Domain model or you can spell it out if you're not using >>>>>> bidirectional >>>>>> associations. You can write an override mapping that just spells out the >>>>>> mapping details you can't get from convention, or where you want to >>>>>> change >>>>>> the convention. >>>>>> >>>>>> I could be wrong about whether it's possible, but you have to ask at >>>>>> what point you're relying too much on conventions. >>>>>> >>>>>> >>>>>> On Wed, May 22, 2013 at 9:37 AM, Riderman Sousa < >>>>>> riderma...@bindsolution.com> wrote: >>>>>> >>>>>>> How to do In many to many relationship, where no child class. >>>>>>> How to generate a table by convention linking the two? >>>>>>> >>>>>>> *Tables to be generate:* >>>>>>> table Person >>>>>>> Id >>>>>>> Name >>>>>>> >>>>>>> table Company >>>>>>> Id >>>>>>> Name >>>>>>> >>>>>>> table PersonCompany >>>>>>> PersonId >>>>>>> CompanyId >>>>>>> >>>>>>> *Current class* >>>>>>> class Person >>>>>>> string Name >>>>>>> >>>>>>> class Company >>>>>>> string Name >>>>>>> IList<Person> Persons >>>>>>> >>>>>>> As you can see, there are no IList<Company> child property on class >>>>>>> Person. >>>>>>> How to generate a second table (PersonCompany) by convention in >>>>>>> this case? >>>>>>> >>>>>>> Riderman de Sousa Barbosa <http://about.me/ridermansb> >>>>>>> >>>>>>> Web Developer | MCPD Certify >>>>>>> >>>>>>> Skype.: 4042-6002 | Cel.: (31) 8681-1986 >>>>>>> bindsolution.com >>>>>>> >>>>>>> Microsoft Parner Network >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Fluent NHibernate" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>>>>> To post to this group, send email to >>>>>>> fluent-nhibernate@googlegroups.com. >>>>>>> Visit this group at >>>>>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Fluent NHibernate" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>>>> To post to this group, send email to >>>>>> fluent-nhibernate@googlegroups.com. >>>>>> Visit this group at >>>>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Fluent NHibernate" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>>> To post to this group, send email to >>>>> fluent-nhibernate@googlegroups.com. >>>>> Visit this group at >>>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Fluent NHibernate" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>> To post to this group, send email to fluent-nhibernate@googlegroups.com >>>> . >>>> Visit this group at >>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Fluent NHibernate" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>> To post to this group, send email to fluent-nhibernate@googlegroups.com. >>> Visit this group at >>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to fluent-nhibernate+unsubscr...@googlegroups.com. >> To post to this group, send email to fluent-nhibernate@googlegroups.com. >> Visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to fluent-nhibernate+unsubscr...@googlegroups.com. > To post to this group, send email to fluent-nhibernate@googlegroups.com. > Visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.