Forum Discussion

pwendel's avatar
pwendel
Copper Contributor
Aug 01, 2024

C# & EF Core : 2 databases with a Customertable and different Columns

Hello,

I have a little PRoblem with my DbContext.

For Example: I have two Databases both have a Table Customer. One of the Customers has an Extension of our Software so in the Customertable there are for example 3 more columns. 

Now when i create the DataAccess Class of the Customer Table i add the Structure from the Customer Table and the 3 extra columns. Now when i Request a Customer for the Customer with the extra Columns all is fine. The Request for the other Customer gets an Error that the last 3 Columns from the Model are not in the Table. 

Unfortunately it is not possible to add the Columns to the other Customer Table.

so my Question is: Is there another Way to geht Records from both Databases with one Model Class and one DBContext?

I tried NotMapped and Required in DbContext, I tried Raw SQL but nothing worked. The only Solution is to create 2 DbContexts. But in Our Database there are more such Combinations of Table with different Columns.

Can anyone help or provide a way to test?

Best Regards

Philipp

No RepliesBe the first to reply

Resources