Sparc.Blossom.Data.Cosmos 7.1.0

There is a newer version of this package available.
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                
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.Blossom.Data.Cosmos" Version="7.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sparc.Blossom.Data.Cosmos --version 7.1.0                
#r "nuget: Sparc.Blossom.Data.Cosmos, 7.1.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.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

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.Blossom.Core documentation.

For an example on using IRepository<T> inside a Feature, see the examples in the Sparc.Features documentation.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
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
8.0.0 104 7/21/2024
7.1.0 174 5/10/2023
7.1.0-pre.2 130 12/13/2022