locked
How to add multiple databases for a single frontend RRS feed

  • Question

  • We have a project based on distributed databases and we have to workout on .Net framework.I want to know some information of connecting multiple databases for a single frontend and how can we access them.

    If so we have connected 2 databases for a single frontend in future if I want add one more database to it how it will be possible to do it without disturbing the current connectivity.

    Please help me in resolving this problem.

    Thanks......

    Wednesday, February 11, 2015 4:50 AM

Answers

  • hi,

    what do you mean by connecting 2 databases? can you explain further?

    using entityframework you can connect to different databases

      public class CustomerContext : DbContext
        {
            public ReportContext()
                : base("DefaultConnection")
            {
            }
    
            public DbSet<Customers> Customers { get; set; }
        }

    and your connectionstring (config file)

    <connectionStrings>
        <add name="DefaultConnection" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\\Database\Project.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
      </connectionStrings>

    you can add more connection strings on it.

    https://msdn.microsoft.com/en-us/library/vstudio/cc716756(v=vs.100).aspx

    https://msdn.microsoft.com/en-us/library/ms254978(v=vs.110).aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 11, 2015 5:39 AM

All replies