【发布时间】:2010-08-03 09:48:51
【问题描述】:
嗨,使用流畅的 nibernate 自动映射
映射这个
public virtual int Id { get; set; }
/*...snip..*/
public virtual MapMarkerIcon MapMarkerIcon { get; set; }
}
到这里
CREATE TABLE [Attraction](
[Id] [int] IDENTITY(1,1) NOT NULL,
[MapMarkerIconId] [int] NULL
)
用这个:
var cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString)
.DefaultSchema("xxx"))
.Mappings(m =>
{
m.AutoMappings
.Add(
AutoMap.AssemblyOf<Partner>().Where(
n => n.Namespace == "xxx.Core.Domain")
);
m.FluentMappings.Conventions.Add(PrimaryKey.Name.Is(x => "Id"),
DefaultLazy.Always(),
ForeignKey.EndsWith("Id")
);
}
)
.ExposeConfiguration(c => c.SetProperty(Environment.ReleaseConnections, "on_close"))
.ExposeConfiguration(c => c.SetProperty(Environment.ProxyFactoryFactoryClass, typeof(ProxyFactoryFactory).AssemblyQualifiedName))
.BuildConfiguration();
我为什么会得到
“/XXX.Web”中的服务器错误 应用。列名无效 'MapMarkerIcon_id'。
如何让 fluentnibernate 使用 MapMarkerIconId 而不是 MapMarkerIcon_id?
【问题讨论】: