http://fabiomaulo.blogspot.com/2009/06/auto-quote-tablecolumn-names.html
2011/3/8 Charlie <[email protected]> > Hola a todos > > Al momento de generar el schema de mi dominio. Una entidad me esta dando > lata lo raro es que al parecer el mapping es correcto. > > Sin embargo me llamo la atención el problema por eso lo aisle > > > En si tengo 3 clases > > > User, Profile, UserProfile > > Esto es un simple modelo de seguridad. Donde un usuario puede tener n > perfiles > > > El problema se esta dando en UserProfile, Aqui la clase > > * public class UserProfile : IntEntity* > * {* > * public virtual User User { get; set; }* > * > * > * public virtual Profile Profile** { get; set; }* > * > * > * public virtual DateTime RegistrationDate ** { get; set; }* > * > * > * public virtual int Version** { get; set; }* > * > * > * public virtual User LastUser** { get; set; }* > * }* > > Este es el mapping > > <?xml version="1.0" encoding="utf-8"?> > <hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > namespace="SchemaExportTest.Entities" > assembly="SchemaExportTest" > xmlns="urn:nhibernate-mapping-2.2"> > <class name="UserProfile"> > <id name="Id" type="Int32"> > <generator class="hilo"> > <param name="table">NextHighVaues</param> > <param name="column">NextHigh</param> > <param name="max_lo">100</param> > <param name="where">Entity = 'UserProfile'</param> > </generator> > </id> > <version name="Version" /> > <many-to-one name="User" column="[user]" /> > <many-to-one name="Profile" column="[profile]" /> > <property name="RegistrationDate" /> > <many-to-one name="LastUser" column="[lastuser]" /> > </class> > </hibernate-mapping> > > > Este es el setup del test > > [SetUp] > public void Configure() > { > _configuration = new Configuration(); > _configuration.AddAssembly(typeof(User).Assembly); > _sessionFactory = _configuration.BuildSessionFactory(); > var schema = new SchemaExport(_configuration); > schema.Create(true, true); > } > > > Ahora este es el sql que se genera para enviar a la bd > > create table UserProfile (Id INT not null, Version INT not null, [user] INT > null, [profile] INT null, RegistrationDate DATETIME null, [lastuser] INT > null, User INT null, primary key (Id)) > > > Como pueden observar se esta enviando "User" como un campo mas y ademas sin > corchetes y por esto truena, Aun no encuentro exactamente donde sucede esto > pero creo que cambiare el nombre a mis entidades. Sin embargo les dejo un > pequeño test por si también desean ver en donde el problema > > En test hay que hacer referencia a los ensamblados de nhibernate, > nunit.framework, castle y no recuerdo si a alguno mas > > Saludos > > > > -- > Para escribir al Grupo, hágalo a esta dirección: > [email protected] > Para más, visite: http://groups.google.com/group/NHibernate-Hispano -- Fabio Maulo -- Para escribir al Grupo, hágalo a esta dirección: [email protected] Para más, visite: http://groups.google.com/group/NHibernate-Hispano
