如何使用FluentNHibernate在ManyToMany生成的表中添加额外的字段 [英] How to add extra field in the ManyToMany generated table with FluentNHibernate

查看:210
本文介绍了如何使用FluentNHibernate在ManyToMany生成的表中添加额外的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个实体用户和颜色。一个用户可能与多种颜色相关联,一种颜色可能与多个用户相关联。
我使用FluentNHibernate autopersistence模型来生成数据库。现在我必须添加到生成的表UserToColor(UserId,ColorId)还有一个额外的字段'CreatedOn',我该如何完成,这是否与流利nhibernate完成?

解决方案

NHibernate不支持这个。最好的解决方法是创建一个额外的类作为一个链接表,并有从你的每个现有的类多对一的关系。


I have 2 entities Users and Colors. One user may be associated with multiple colors, and one color may be associated with multiple users. I use FluentNHibernate autopersistence model to generate the database. Now I have to add to the generated table UserToColor(UserId,ColorId) also an extra field 'CreatedOn', how can I accomplish and is this accomplishable with fluent-nhibernate?

解决方案

NHibernate doesn't support this. The best workaround is to create an extra class as a link table, and have a many to one relationship to it from each of your existing classes.

这篇关于如何使用FluentNHibernate在ManyToMany生成的表中添加额外的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆