Multiple Data Sources Blazor Server Hosted on IIS

Mikaela Caron 41 Reputation points
2020-11-17T18:49:54.357+00:00

I have a Blazor Server project that will be hosted on IIS.

I was using this tutorial by IAmTimCorey to get data from SQL Server. This worked perfectly, but now I want to add another data source to pull data from for different Razor Component (page).

I know how to add another connection string to appsettings.json, but how do I access the second data source and create a service (like Tim's video) to use the 2nd data source?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,863 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,580 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,938 questions
{count} votes

Accepted answer
  1. Brando Zhang-MSFT 3,696 Reputation points Microsoft Vendor
    2020-11-19T06:30:11.467+00:00

    That makes sense! I wasn't sure if you could do it all in one project.

    But having multiple projects for the different data sources sounds like a good solution. Thank you!!

    ----------

    You could also put it all in one project, but you still need add the different data class and sql dat class.

    But I don't suggest you use multiple database in one project. Normally, we will use just one database with multiple table in one project. Using multiple database in one project will make your project become more complex than before and may causing some develop risk.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.