Sparc.Database.Cosmos 7.0.0

.NET 7.0
dotnet add package Sparc.Database.Cosmos --version 7.0.0
NuGet\Install-Package Sparc.Database.Cosmos -Version 7.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sparc.Database.Cosmos" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sparc.Database.Cosmos --version 7.0.0
#r "nuget: Sparc.Database.Cosmos, 7.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

Nuget

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:

  1. Add the Sparc.Database.Cosmos Nuget package: Nuget

  2. Add the following settings to your appsettings.json file:

     {
      "ConnectionStrings": {
        "CosmosDb": "[your Cosmos DB Connection String]"
       }
     }
    
  3. 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);
       }
     }
    
  4. Add the following line of code to your Startup.cs file in your Features Project to register the Sparc.Database.Cosmos plugin. Pass in the DbContext class type you created, the connection string from your appsettings.json file, and the name of your database.

    services.AddCosmos<MyAppContext>(Configuration.GetConnectionString("CosmosDb"), "[your Database Name]");
    
  5. 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
.NET net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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 199 11/7/2022
6.0.8 358 4/11/2022
6.0.7 305 4/8/2022
6.0.6 307 3/28/2022
6.0.5 298 3/9/2022
6.0.2 331 1/10/2022
6.0.1 211 12/17/2021
6.0.0 216 11/19/2021
2.7.0 276 11/9/2021
2.5.1 258 9/1/2021
2.5.0 295 5/6/2021
2.0.18 297 4/8/2021
2.0.11 306 3/9/2021
2.0.8 256 3/9/2021
2.0.7 248 3/9/2021
2.0.6 259 3/9/2021
2.0.5 308 3/3/2021
2.0.1 282 2/22/2021