Devart.Data.MongoDB.EFCore
1.0.248.11
Prefix Reserved
dotnet add package Devart.Data.MongoDB.EFCore --version 1.0.248.11
NuGet\Install-Package Devart.Data.MongoDB.EFCore -Version 1.0.248.11
<PackageReference Include="Devart.Data.MongoDB.EFCore" Version="1.0.248.11" />
<PackageVersion Include="Devart.Data.MongoDB.EFCore" Version="1.0.248.11" />
<PackageReference Include="Devart.Data.MongoDB.EFCore" />
paket add Devart.Data.MongoDB.EFCore --version 1.0.248.11
#r "nuget: Devart.Data.MongoDB.EFCore, 1.0.248.11"
#:package Devart.Data.MongoDB.EFCore@1.0.248.11
#addin nuget:?package=Devart.Data.MongoDB.EFCore&version=1.0.248.11
#tool nuget:?package=Devart.Data.MongoDB.EFCore&version=1.0.248.11
dotConnect for MongoDB
dotConnect for MongoDB is an ADO.NET data provider for MongoDB. Its built-in SQL engine exposes MongoDB collections as tables, and Entity Framework Core works over it: LINQ queries are translated to SQL, and SaveChanges inserts, updates and deletes documents.
More information at dotConnect for MongoDB.
Compatibility
The following table show which version of this package to use with which version of frameworks.
| Frameworks | Version support |
|---|---|
| Entity Framework Core | 11 |
| .NET | 11 |
Installation
For projects using Entity Framework Core 11 with MongoDB, install this package. Execute the following command in the Package Manager Console:
Install-Package Devart.Data.MongoDB.EFCore
MongoDB C Driver
The provider works through the MongoDB C Driver 1.23 (libmongoc). The Devart.Data.MongoDB package carries it for Windows x86 and x64 - libmongoc-1.0.dll, libbson-1.0.dll, sqlite3.dll of the SQL engine and the Visual C++ runtime vcruntime140.dll - and they are copied to the build output: into runtimes\win-x86|x64\native for .NET, into the Native\win-x86 / Native\win-x64 subfolders for .NET Framework. To use other copies, specify their folder with the Native Library Path connection string parameter.
License
See pricing options for ordering.
The NuGet package initiates the retrieval of an activation key from the Devart website. This key is required to activate the product for a free trial.
Usage
This snippet configures a MongoDB connection for an Entity Framework Core DbContext using a connection string.
public class MyDbContext : DbContext {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseMongoDB("Host=localhost;Port=27017;Database=test;User Id=user;Password=password;Sql Engine=True;License Key=**********");
}
}
The key of an entity is the _id field. A single string key (and a key of the ObjectId type of the MongoDB driver) gets a client-generated ObjectId and is stored as an ObjectId, as are the foreign keys that reference it. To store string keys of your own, configure the key with ValueGeneratedNever(); HasColumnType("text") keeps a generated key a string. Guid keys get a client-generated Guid. On a replica set or a sharded cluster SaveChanges runs in a MongoDB transaction. A standalone server has no transactions: there the changes are applied one by one, and a failure leaves the changes made before it. Set Transactions=Required in the connection string to get an error instead.
- An owned type (
OwnsOne) is stored as an embedded document, a collection of an owned type (OwnsMany) as an array of embedded documents. LINQ queries filter on their fields (c.Address.City == "Rome",c.Phones.Any(p => p.Kind == "home")); a condition on a field of an embedded document goes to MongoDB.Scaffold-DbContextmakes owned types of the embedded documents and of the arrays of embedded documents. UseCamelCaseFieldNames()names the fields in camel case.EnableRetryOnFailure()retries the operations that fail with a transient error.
Basic Connection Strings
| Property | Meaning |
|---|---|
| Host | The name or IP address of the MongoDB server. |
| Port | The port of the MongoDB server, 27017 by default. |
| Database | The database to work with. |
| User Id | The user name. |
| Password | The password of the user. |
| Sql Engine | If True, the collections are queried with SQL as tables; if False, the commands are native MongoDB JSON commands. |
| License Key | Specify your license key in this parameter. |
Related Packages
Support Area
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Devart.Data.MongoDB (>= 1.0.248)
- Microsoft.EntityFrameworkCore.Relational (>= 11.0.0 && < 12.0.0)
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 |
|---|---|---|
| 1.0.248.11 | 0 | 11/12/2026 |
| 1.0.248.10 | 0 | 11/12/2026 |
| 1.0.248.9 | 0 | 11/12/2026 |
| 1.0.248.8 | 0 | 11/12/2026 |
| 1.0.248 | 0 | 11/12/2026 |