实体框架和 MongoDb
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6798304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Entity Framework and MongoDb
提问by Chance
Is it possible that Entity Framework supports MongoDb database? Maybe somebody will write a EF MongoDb Provider?
Entity Framework 有没有可能支持 MongoDb 数据库? 也许有人会写一个 EF MongoDb Provider?
回答by Andrew Orsich
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.
MongoDB 是文档数据库,不支持集合之间的任何物理关系。EF 非常适合 SQL、MySQL 等关系数据库。MongoDB 处理嵌入式文档的速度更快。所以这只是两种不同的方法。
回答by reach4thelasers
Check out the latest version of the MongoDB C# Library.... supports LINQ!
查看最新版本的 MongoDB C# 库.... 支持 LINQ!
回答by Jone Polvora
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
我是实体框架的忠实粉丝,所以当我第一次尝试使用 mongoDb 时,我创建了一个名为“MongoDB.Dynamic”的库,它的方法类似于 EF Code First。MongoDB 在物理上没有集合之间的关系,但您可以模拟它。MongoDB.Dynamic 有一个称为 Eager Loading 的功能,如果实体具有约定结构,您可以配置集合之间的关系并自动加载相关文档。您可以尝试阅读MongoDB.Dynamic 上的一些文档
回答by chris31389
Looking online, RSSBus look to have created a MongoDBProviderServices dll that could be used with entity framework 6.
在线查看,RSSBus 看起来已经创建了一个 MongoDBProviderServices dll,可以与实体框架 6 一起使用。
http://cdn.rssbus.com/help/DG1/ado/pg_ef6.htm
http://cdn.rssbus.com/help/DG1/ado/pg_ef6.htm
The link includes a tutorial on how to implement it.
该链接包含有关如何实现它的教程。
回答by Vladislav Furdak
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.
我不建议使用使用 LINQ 的旧版本 MongoDb 提供程序。最好且稳定的 C# MongoDb 驱动程序是官方的 MongoDb 驱动程序 2.0 for C#,它使用 Builders 机制。
The LINQ legacy driver has many constraints with inconvenient and slow Bulk insert mechanism.
LINQ 传统驱动程序有许多限制,包括不方便和缓慢的批量插入机制。
回答by Faisal Ahmed
CData developed a library for doing CRUD operations with MongoDb using Entity Framework 6.0. But its not free.
CData 开发了一个库,用于使用 Entity Framework 6.0 与 MongoDb 进行 CRUD 操作。但它不是免费的。
Details of the library can be found in
图书馆的详细信息可以在