I renamed the Relation field back to ParentRelation and modified the
VariableMap back to this:
public class VariableMap : ClassMap<Variable>
{
public VariableMap()
{
Id(x => x.Id);
References(x => x.ParentRelation)
.WithForeignKey("Relation_id")
.TheColumnNameIs("Relation_id")
.Cascade.All();
}
}
The appropriate columns are now created, but the cascading no longer
works. :( Relation seems to have been created, but the Variable
information was not. Is there a bug in here somewhere?
Actually, I just tried running the FirstExample project from the trunk
again (which I was using as an example for my own project here). When
I replaced the configuration to point to SQL Server (see below for
modified CreateSessionFactory method) the References relationship does
not work there either ... I really think there is a bug here with the
References or HasMany methods, either that or its my configuration,
but my config is pretty basic. Try the FirstExample project but
examine the database after it has run (save it to SQL Server or
something) and see if the information is actually persisted in the
tables or not.
private static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString(x => x.Is
(@"Server=BUMBLEBEE
\SQLEXPRESS;Database=EditImputation;Trusted_Connection=True;"))
.ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<Program>())
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
}
On Feb 12, 3:59 am, James Gregory <
jagregory....@gmail.com> wrote:
> Sorry, that should have been WithKeyColumn rather than TheColumnNameIs.
>
> On Thu, Feb 12, 2009 at 8:58 AM, James Gregory <
jagregory....@gmail.com>wrote:
>
> > Your table is ending up with three columns because the HasMany in Relation
> > is called Variables but the other side of the relation is called
> > ParentRelation; this is causing FNH to not see them as two sides of the same
> > relationship. Try calling TheColumnNameIs on your ParentRelation and giving
> > it "Relation_id".
> > Making that change might actually fix your saving issue.
>
> ...
>
> read more »