Entity Framework and MongoDb

Entity FrameworkOrmMongodb

Entity Framework Problem Overview


Is it possible that Entity Framework supports MongoDb database? Maybe somebody will write a EF MongoDb Provider?

Entity Framework Solutions


Solution 1 - Entity Framework

Short answer - no, it's for sure possible, but not reasonable.

MongoDB is document database and not support any physical relations between collections. EF is a good fit for relational databases like SQL, MySQL, etc. MongoDB works faster with embedded documents. So it's just two different approaches.

Solution 2 - Entity Framework

Check out the latest version of the MongoDB C# Library.... supports LINQ!

https://mongodb.github.io/mongo-csharp-driver/1.11/linq/

Solution 3 - Entity Framework

I'm a big fan of entity framework, so when I first tried out mongoDb I've created a library called "MongoDB.Dynamic" that has an approach next to EF Code First. MongoDB has no relations between collections physically, but you can simulate it. MongoDB.Dynamic has a feature known as Eager Loading that you can configure relationships between collections and load related documents automatically if an entity have the conventioned structure. You can try and read some documentation at MongoDB.Dynamic

Solution 4 - Entity Framework

Looking online, RSSBus look to have created a MongoDBProviderServices dll that could be used with entity framework 6.

http://cdn.rssbus.com/help/DG1/ado/pg_ef6.htm

The link includes a tutorial on how to implement it.

Solution 5 - Entity Framework

CData developed a library for doing CRUD operations with MongoDb using Entity Framework 6.0. But its not free.

Details of the library can be found in

https://www.cdata.com/kb/tech/mongodb-ado-codefirst.rst

Solution 6 - Entity Framework

I do not suggest to use the old version of MongoDb provider that uses LINQ. The best and stable C# MongoDb driver is the official MongoDb driver 2.0 for C# that uses Builders mechanics.

The LINQ legacy driver has many constraints with inconvenient and slow Bulk insert mechanism.

Solution 7 - Entity Framework

I am not sure, but I think the Microsoft.EntityFrameworkCore.Cosmos Database Provider will work for you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChanceView Question on Stackoverflow
Solution 1 - Entity FrameworkAndrew OrsichView Answer on Stackoverflow
Solution 2 - Entity Frameworkreach4thelasersView Answer on Stackoverflow
Solution 3 - Entity FrameworkJone PolvoraView Answer on Stackoverflow
Solution 4 - Entity Frameworkchris31389View Answer on Stackoverflow
Solution 5 - Entity FrameworkFaisal AhmedView Answer on Stackoverflow
Solution 6 - Entity FrameworkVladyslav FurdakView Answer on Stackoverflow
Solution 7 - Entity FrameworkGuruKayView Answer on Stackoverflow