c# – Working with multiple databases at the same time


I am creating a calculator application in which the user creates a calculation formula and is saved in the SQL Server Database , you need to implement a connection to the database with the initial data, from where the table comes from, the column of which is related to the variable in the formula. Hence it turns out that I need to work with two tables at the same time. Is it possible to work with two databases at the same time? As far as I understand, the connection goes through a connectionString, which is only one, where you can specify only one connection, how to implement it, is it possible with Entity Framework or do it in pure C #?


You are wrong, you can use more than one ConnectionString, it looks something like this:

    <add name="FirstDb" connectionString="Data Source=|DataDirectory|\FirstDb.sdf" providerName="System.Data.SqlServerCe.4.0" />
    <add name="SecondDb" connectionString="Data Source=|DataDirectory|\SecondDb.sdf" providerName="System.Data.SqlServerCe.4.0" />

Well, the context is needed for two databases at once.

Scroll to Top