开发者

Fluent NHibernate Auto Mapping table to fully qualified name

开发者 https://www.devze.com 2022-12-21 17:19 出处:网络
I\'m using Fluent NHibernate auto mapping. I need to access more than one database on the same server is it ok to override the table name with the fully qualified name. For example my开发者_Go百科 con

I'm using Fluent NHibernate auto mapping. I need to access more than one database on the same server is it ok to override the table name with the fully qualified name. For example my开发者_Go百科 connection string is configured to Db1 but I need to access table Company on Db2 on the same server. I tested the code below and it seems to work I'm just wondering if this will cause problems down the road.

  public void Override(AutoMapping<Customer> mapping)
  {
      mapping.Table("db2.dbo.Company");
  }


As far as NHibernate is concerned, this is just a table name. If you someday rename the other database, or the table, or move the table into Db1, all you would need to do is change that table mapping.

The only issue I would have with doing this is that your application database (Db2) is no longer self contained. Your app and the app that "owns" Db1 have that table as an integration point.

0

精彩评论

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