Search code examples
nhibernatenhibernate-mapping

How to specify Schema for Lists while mapping Nhibernate by code


I want my "tag_post" table to be created in "article" schema but it's created in "public" schema.

List(x => x.Tags, l =>
        {
            l.Where("deleted = 0");

            l.Key(k =>
            {
                k.Column("post_id");
                k.NotNullable(true);
            });
            Schema(Constants.DatabaseSchemaNames.Article);
            l.Table("tag_post");
        }, x =>
        {
            x.ManyToMany(m => m.Column("tag_id"));
        });

Solution

  • I have never used mapping by code, but i assume this is the solution:

    List(x => x.Students, l =>
    {
        l.Where("deleted = 0");
    
        l.Key(k =>
        {
            k.Column("post_id");
            k.NotNullable(true);
        });
        l.Schema(Constants.DatabaseSchemaNames.Article);
        l.Table("tag_post");
    }, x =>
    {
        x.ManyToMany(m => m.Column("tag_id"));
    });