Sparc.Database.Cosmos
7.0.0
dotnet add package Sparc.Database.Cosmos --version 7.0.0
NuGet\Install-Package Sparc.Database.Cosmos -Version 7.0.0
<PackageReference Include="Sparc.Database.Cosmos" Version="7.0.0" />
paket add Sparc.Database.Cosmos --version 7.0.0
#r "nuget: Sparc.Database.Cosmos, 7.0.0"
// Install Sparc.Database.Cosmos as a Cake Addin #addin nuget:?package=Sparc.Database.Cosmos&version=7.0.0 // Install Sparc.Database.Cosmos as a Cake Tool #tool nuget:?package=Sparc.Database.Cosmos&version=7.0.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.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.Core (>= 7.0.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 |
---|---|---|
7.0.0 | 389 | 11/7/2022 |
6.0.8 | 576 | 4/11/2022 |
6.0.7 | 451 | 4/8/2022 |
6.0.6 | 449 | 3/28/2022 |
6.0.5 | 456 | 3/9/2022 |
6.0.2 | 477 | 1/10/2022 |
6.0.1 | 324 | 12/17/2021 |
6.0.0 | 305 | 11/19/2021 |
2.7.0 | 385 | 11/9/2021 |
2.5.1 | 342 | 9/1/2021 |
2.5.0 | 393 | 5/6/2021 |
2.0.18 | 418 | 4/8/2021 |
2.0.11 | 405 | 3/9/2021 |
2.0.8 | 379 | 3/9/2021 |
2.0.7 | 339 | 3/9/2021 |
2.0.6 | 357 | 3/9/2021 |
2.0.5 | 403 | 3/3/2021 |
2.0.1 | 399 | 2/22/2021 |