hello people:
I am presenting a problem when mapping the following classes to tables
for a SQLServer database

    public partial class Persona
    {
        public virtual long PerIdPer { get; set; }
        public virtual string Per1erNombre { get; set; }
        public virtual string Per2doNombre { get; set; }
        public virtual string Per1erApellido { get; set; }

    }

    public partial class Foto
    {
        public virtual long IdFoto { get; set; }
        public virtual byte[] ImagenRostro { get; set; }
        public virtual Persona IdPersona { get; set; }
    }

As you can see, the class Foto has an object of type Persona, then I
show the respective classes for the mapping

    public class PersonaMap: ClassMap<Persona>
    {
        public PersonaMap()
        {
            Table("P_PERSONA");
            Id(x =>
x.PerIdPer).Column("PER_ID_PER").GeneratedBy.Assigned().CustomSqlType( "DECIMAL
(20)");

            Map(x =>
x.Per1erNombre).Column("PER_1ER_NOM").CustomSqlType("NVARCHAR(30)");
            Map(x =>
x.Per2doNombre).Column("PER_2DO_NOM").CustomSqlType("NVARCHAR(30)");
            Map(x =>
x.Per1erApellido).Column("PER_1ER_APE").CustomSqlType("NVARCHAR(30)");
        }
    }

    public class FotoMap : ClassMap<Foto>
    {
        public FotoMap()
        {

            Table("P_FOTO");
            Id(x =>
x.IdFoto).Column("FOTO_ID_FOTO").GeneratedBy.Assigned().CustomSqlType("DECIMAL(20)");
            References(x =>
x.IdPersona).Column("PER_ID_PER").Not.LazyLoad().ForeignKey("P_FOTO_PK_PER_ID_PER");

            Map(x =>
x.ImagenRostro).Column("FOTO_ROSTRO").CustomSqlType("IMAGE");
        }
    }

now see the SQL syntax generated by these two class of mapping

    create table P_PERSONA (
        PER_ID_PER DECIMAL(20) not null,
       PER_1ER_NOM NVARCHAR(30) null,
       PER_2DO_NOM NVARCHAR(30) null,
       PER_1ER_APE NVARCHAR(30) null,
       primary key (PER_ID_PER)
    )

    create table P_FOTO (
        FOTO_ID_FOTO DECIMAL(20) not null,
       FOTO_ROSTRO IMAGE null,
       PER_ID_PER BIGINT null,
       primary key (FOTO_ID_FOTO)
    )

as you can see, the field PER_ID_PER P_PERSONA table is of type
DECIMAL (20)
but the field PER_ID_PER P_FOTO table, referring to the table
P_PERSONA, is bigint

why the project throws the following exception
{"Column 'P_PERSONA.PER_ID_PER' is not the same data type as
referencing column 'P_FOTO.PER_ID_PER' in foreign key
'P_FOTO_PK_PER_ID_PER'.\r\nCould not create constraint. See previous
errors."}

what can I do??
Thanks a lot

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to