8 SQL database integrations

 

This chapter covers

  • Integrating .NET Aspire with a SQL Server component
  • Working with Oracle Aspire integration
  • Using PostgreSQL inside a distributed Aspire application
  • Using MySQL inside .NET Aspire

.NET Aspire can be integrated with SQL-based relational database management systems (RDBMS) via Aspire integration libraries. At the time of writing, the following relational database types are supported:

  • SQL Server (including a bespoke Azure version)
  • Oracle
  • PostgreSQL
  • MySQL

Any enterprise-grade application relies on data; therefore, it has data storage technologies integrated with it. SQL-based relational databases are the most popular category of databases used in these types of applications.

As we shall see in this chapter, .NET Aspire integrations make it significantly easier to add an RDBMS to your application. For example, you no longer have to manage database connection strings yourself. The .NET Aspire service discovery mechanism will do it all for you! In this case,

Moreover, the integration libraries work both with and without the object-relational mapper, like Entity Framework. Therefore, you can use the SQL-based databases in the way that you prefer and are accustomed to.

In this chapter, we will go through all the main SQL integrations available with .NET Aspire. But before we talk about the individual SQL database types, we will talk about the general principles that all the RDBMS integrations follow.

8.1 SQL Database components basics

8.1.1 Connecting .NET Aspire to an existing database

8.2 Hosting an SQL Server component

8.2.1 Consuming an SQL Server integration

8.2.2 Using Entity Framework

8.2.3 Integrating with Azure SQL Server

8.3 Hosting an Oracle component

8.3.1 Oracle client integration

8.4 Hosting a PostgreSQL component

8.4.1 PostgreSQL client integrations

8.5 Hosting a MySQL component

8.5.1 MySQL client integration

8.6 Summary