Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework like ORM for Cosmos DB

I am looking for any ORM for Cosmos DB. Most of the client which have been mentioned in samples create a new connection to table when they need i.e. there is no connection pooling policy. It seems creating new connection always as is given in samples is non scalable. Please correct me if I am wrong. And does anyone have any good ORM solution which comes with connection pooling

like image 853
Akshat Avatar asked Jul 01 '18 15:07

Akshat


2 Answers

Cosmonaut is exactly what you're looking for.

It is a simple and minimalistic object mapper, which creates a collection-to-object relationship. You can use your POCO objects and do all the CRUD operations.

The idea is pretty simple. You can have one CosmosStore per entity (POCO/dtos etc). This entity will be used to create a collection or use part of a one in Cosmos DB and it will offer all the data access for this object. It is optimized for performance out of the box and takes a lot of efficient decisions for you.

It supports collection sharing in order to reduce the cost of having multiple objects in one collection as well.

Read more about Cosmonaut here.

Disclaimer, I am the creator of Cosmonaut.

like image 169
Nick Chapsas Avatar answered Oct 03 '22 22:10

Nick Chapsas


Cosmos DB now supports Entity Framework (announcement) (although at this point at the preview state); but works quite nicely.

p.s. nice 3rd party guide with more details on how to set things up:

However, you should really think whether you need EF (ORM). It is probably useful if you are switching you db to CosmosDB; and don't want to change your EF code right away; note though that in any case switching dbs requires work on EF-front; even more so if switching db types: relational to NoSQL.

EF does ORM (object to db mapping); however NoSQL already has object mapping so EF is not really needed (actually unnecessarily complicates things.

There is a nice write up from Microsoft on the related topics: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/nosql-database-persistence-infrastructure

like image 24
Neil Avatar answered Oct 03 '22 23:10

Neil