A simplistic application that uses the official MongoDB Entity Framework Core Provider.
NuGet: NuGet Gallery | MongoDB.EntityFrameworkCore 7.0.0-preview.1
Repo: mongodb/mongo-efcore-provider: MongoDB Entity Framework Core Provider (github.com)
Docs: MongoDB Entity Framework Core Provider — Entity Framework
Entity Framework has long been available to attempt to smooth unify and unify the tasks of storing .NET entities in a backing relational database.
The MongoDB provider for EF is an effort to give similar EF user experience, but with a document database backing.
Note: The current provider is in preview status.
So... this will age nicely :-)
- In the 8.0 GA release, both
BsonElementAttribute()
(MongoDB) andColumnAttribute()
(EF / Data Annotation) are respected. You can name the MongoDB side field and keep your POCO names as you wish. - Applying
[BsonRepresentation(..)]
to a POCO attribute throws. - Applying
[BsonId]
attribute to a field on a POCO works - you can choose which property will map to the MongoDB document's_id
field. - Using the ModelBuilder to set property behavior such as conversion POCO <--> BSON, value generation etc demo updated, for specific properties.