1
votes

I've got an ASP.NET MVC (VB) project with two models that represent two different databases. Each model needs to include a table from its database with the same name. For example, model1.dbml needs to have db1.MyTable in it, and model2.dbml needs to have db2.MyTable in it.

I can't do this because both models try to create a "Partial Public Class MyTable", and both have "Public Sub New()", so you get the "multiple definitions with identical signatures" error.

There is a potential for a number of the tables between the models to have the same name. (These are separate instances of the same product used for different lines of business.) How do you get around this? Do I have to change every one of the names in one of the models to be unique? Is there a better way?

2
which framework are you using to generate your Models - Rony
LINQ to SQL (on a SQL Server database). - gfrizzle

2 Answers

2
votes

In the properties for the data context, there's an entity namespace property. Change that to be different for each one.

Here is the screenshot. alt text http://img386.imageshack.us/img386/5224/98530173.jpg

1
votes

There is a code smell to this. If your two databases are really two separate and distinct entities, then why are they in the same project; and if they are not two separate entities, then why are there two separate databases?

If you are working with one application in a portal configuration (multiple companies), then the separation can take place using a CompanyID field as a filter, and there is only ONE set of entity classes needed.