开发者

How to change FK Name in fluent nhibernate

开发者 https://www.devze.com 2023-04-05 17:49 出处:网络
I am wondering how do I change the name of a FK with fluent nhibernate. Right now it makes all the foreign keys like (product_id,student_id) what is find but there is one table I wan开发者_JS百科t it

I am wondering how do I change the name of a FK with fluent nhibernate.

Right now it makes all the foreign keys like (product_id,student_id) what is find but there is one table I wan开发者_JS百科t it to have a different name.

I want the courses table to have for the foreign key "MyFKName" but it keeps generating "student_id"

 public CourseMap()
    {
        Id(x => x.Id);
        References(x => x.Student).ForeignKey("MyFKName");
    }


what you are probably looking for is

public CourseMap()
{
    Id(x => x.Id);
    References(x => x.Student).KeyColumn("MyFKName");
}

ForeignKey is the name of the foreign key constraint

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号