c# – Working with multiple databases at the same time

Question:

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 #?

Answer:

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

  <connectionStrings>
    <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" />
  </connectionStrings>

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

Scroll to Top