Sitemap

Azure Cosmos DB — Using EF Core with a NoSQL Database in a .NET Web API

2 min readMar 12, 2024

--

Press enter or click to view image in full size

⚠️ This article has moved to my website.

You can read the latest version here:
👉 https://henriquesd.com/articles/azure-cosmos-db-using-ef-core-with-a-nosql-database-in-a-net-web-api

Below is a short preview of the article.

Azure Cosmos DB is a globally distributed database service that offers high availability, global distribution, automatic scalability and support for multi-data models. Entity Framework Core is an ORM (object-relation mapping) that allows you to work with databases in a .NET application. In this article, I present how to use Entity Framework Core with a NoSQL database in Azure Cosmos DB, in a .NET Web API.

If this is your first contact with Cosmos DB, I have an introductory article that explains the basics of Azure Cosmos DB: Azure Cosmos DB — Getting Started and Creating a NoSQL Database.

Azure Cosmos DB Emulator

To develop applications using Cosmos DB, you can do it by using the Cosmos DB in Azure, or you can use the emulator. The Emulator emulates Cosmos DB service on your own environment, allowing you to develop and test applications without being charged. You can find more information about the emulator on this Microsoft Docs page.

Keep in mind that there are some differences between the emulator and the cloud service, the Data Explorer for example, only fully supports the SQL API.

Once installed, you can search for “Azure Cosmos DB Emulator” and open the emulator:

It might take some time to start, but once started, then you can access https://localhost:8081/_explorer/index.html, and you will see this page where you can find the connection details:

Press enter or click to view image in full size

On the Emulator, you can also access the “Explorer” page where you have similar functionalities as the the Data Explorer in Azure Portal.

For this demo, I created three containers:

👉 Continue reading the full article here: https://henriquesd.com/articles/azure-cosmos-db-using-ef-core-with-a-nosql-database-in-a-net-web-api

--

--