Craig Bart
Craig Bart

Reputation: 75

Fluent NHibernate Auto Mapping table to fully qualified name

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 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");
  }

Upvotes: 0

Views: 510

Answers (1)

Lachlan Roche
Lachlan Roche

Reputation: 25946

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.

Upvotes: 1

Related Questions