Sparc.Blossom.Data.Cosmos
7.1.0
See the version list below for details.
dotnet add package Sparc.Blossom.Data.Cosmos --version 7.1.0
NuGet\Install-Package Sparc.Blossom.Data.Cosmos -Version 7.1.0
<PackageReference Include="Sparc.Blossom.Data.Cosmos" Version="7.1.0" />
paket add Sparc.Blossom.Data.Cosmos --version 7.1.0
#r "nuget: Sparc.Blossom.Data.Cosmos, 7.1.0"
// Install Sparc.Blossom.Data.Cosmos as a Cake Addin #addin nuget:?package=Sparc.Blossom.Data.Cosmos&version=7.1.0 // Install Sparc.Blossom.Data.Cosmos as a Cake Tool #tool nuget:?package=Sparc.Blossom.Data.Cosmos&version=7.1.0
Sparc.Database.Cosmos
The Sparc.Database.Cosmos
plugin is primarily an implementation of IRepository<T>
that uses Azure Cosmos DB via Entity Framework for all of its persistence operations.
Add this plugin to your Features Project if you'd like to use Azure Cosmos DB as your app's database provider.
Get Started with Sparc.Database.Cosmos
In Your Features Project:
Add the following settings to your
appsettings.json
file:{ "ConnectionStrings": { "CosmosDb": "[your Cosmos DB Connection String]" } }
Create an Entity Framework
DbContext
class, configuring all root entities as necessary. Example:public class MyAppContext : DbContext { public MyAppContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { builder.Entity<User>().HasPartitionKey(x => x.UserId); } }
Add the following line of code to your
Startup.cs
file in your Features Project to register theSparc.Database.Cosmos
plugin. Pass in theDbContext
class type you created, the connection string from yourappsettings.json
file, and the name of your database.services.AddCosmos<MyAppContext>(Configuration.GetConnectionString("CosmosDb"), "[your Database Name]");
Inject
IRepository<T>
into any feature that needs to load from or save data to the database. All typically necessary database operations exist within this interface. The Cosmos DB Repository you configured will automatically be used.
More Info
For more information on root entities, or how to use IRepository<T>
, see the Sparc.Blossom.Core documentation.
For an example on using IRepository<T>
inside a Feature, see the examples in the Sparc.Features documentation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Ardalis.Specification.EntityFrameworkCore (>= 6.1.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.EntityFrameworkCore.Cosmos (>= 7.0.0)
- Sparc.Blossom.Core (>= 7.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 106 | 7/21/2024 |
7.1.0 | 176 | 5/10/2023 |
7.1.0-pre.2 | 132 | 12/13/2022 |