views:

90

answers:

1

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");
  }
+1  A: 

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.

Lachlan Roche

related questions