Skip to content

Demonstrates the use of EF Core 3.1 provider for Azure Cosmos DB

Notifications You must be signed in to change notification settings

jsancho/cosmos-efcore-university

Repository files navigation

Cosmos University

This sample project demonstrates how to use Cosmos DB (SQL Api) with EF Core 3.1

The project takes advantage of the TPH (Table per hierarchy) convention to store all types into a single Cosmos container.


                              +----------------+
                              |                |
                              |    Person      |
                              |                |
                              +------+--+------+
                                     ^  ^
                                     |  |
                        +------------+  +--------+
                        |                        |
                 +------+-----+           +------+------+
                 |            |           |             |
                 |   Staff    |           |   Student   |
                 |            |           |             |
                 +----+--+----+           +-------------+
                      ^  ^
         +------------+  +---------+
         |                         |
+--------+---------+        +------+------+
|                  |        |             |
|  Administrative  |        |  Lecturer   |
|                  |        |             |
+------------------+        +-------------+

The partition key for all entities is the /College property.

This is to demonstrate how optimise for reads from a single logical partition.

The idea is that we would be expecting to receive many queries that are concerned with the staff and students of a single college, so this partition caters for that scenario.

Requirements

Azure subscription with a Cosmos DB account

Secret Management

To avoid leaking secrets in source this project uses the dotnet secrets manager

You will need to configure locally your Cosmos https endpoint and its secret

The dotnet cli can help with this

dotnet user-secrets set "CosmosSettings:ServiceEndpoint" "https://your_endpoint_here"

dotnet user-secrets set "CosmosSettings:Secret" "12345"

About

Demonstrates the use of EF Core 3.1 provider for Azure Cosmos DB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages