How does this patch work, for example, with the code given below I
get 4 tables, A, B, AToB & BToA when I'd only expect the one xToy
Table, if I take the IList<A> out of class B ithen lose both xToy
tables and get an FK on the B table (as expected). What am I doing
wrong here?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.AutoMap;
using Entities;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Cfg;
using FluentNHibernate.Cfg;
using NHibernate;
using System.Collections;
using Iesi.Collections.Generic;
namespace AutoMappingTest
{
class Program
{
static void Main(string[] args)
{
Configuration cfg = new Configuration();
var config = MsSqlConfiguration.MsSql2005
.ShowSql()
.ConnectionString.Is("Data Source=.;Initial
Catalog=Testing;Integrated Security=True")
.ConfigureProperties(cfg);
var model = new AutoPersistenceModel
{
Conventions =
{
GetForeignKeyNameOfParent = type => type.Name +
"Id",
GetForeignKeyName = info => info.Name + "Id",
GetManyToManyTableName = ((child,parent)
=>child.Name + "To" + parent.Name)
}
};
model
.AddEntityAssembly(typeof(A).Assembly)
.Where(entity => entity.Namespace == "Entities")
.Configure(config);
SchemaExport exporter = new SchemaExport(config);
exporter.Execute(true, true, false, true);
}
}
}
namespace Entities
{
public class A
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<B> Bees { get; set; }
}
public class B
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<A> Ays { get; set; }
> fluent_nh.patch
> 19KViewDownload