{"id":14350344,"url":"https://github.com/mongodb/mongo-efcore-provider","last_synced_at":"2026-02-06T02:15:47.930Z","repository":{"id":164592903,"uuid":"639890643","full_name":"mongodb/mongo-efcore-provider","owner":"mongodb","description":"MongoDB Entity Framework Core Provider","archived":false,"fork":false,"pushed_at":"2026-01-21T17:32:56.000Z","size":10332,"stargazers_count":390,"open_issues_count":4,"forks_count":39,"subscribers_count":26,"default_branch":"main","last_synced_at":"2026-01-23T17:28:28.871Z","etag":null,"topics":["csharp","entity-framework","entity-framework-core","mongodb"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/MongoDB.EntityFrameworkCore","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-12T13:10:14.000Z","updated_at":"2026-01-21T14:47:44.000Z","dependencies_parsed_at":"2025-12-09T20:03:40.855Z","dependency_job_id":null,"html_url":"https://github.com/mongodb/mongo-efcore-provider","commit_stats":{"total_commits":244,"total_committers":8,"mean_commits":30.5,"dds":"0.49590163934426235","last_synced_commit":"ea954cc9e7706aa963e46504a166db3c13c5084c"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/mongodb/mongo-efcore-provider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-efcore-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-efcore-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-efcore-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-efcore-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/mongo-efcore-provider/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-efcore-provider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29145570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T01:13:33.096Z","status":"online","status_checked_at":"2026-02-06T02:00:08.092Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","entity-framework","entity-framework-core","mongodb"],"created_at":"2024-08-27T04:00:46.027Z","updated_at":"2026-02-06T02:15:47.918Z","avatar_url":"https://github.com/mongodb.png","language":"C#","funding_links":[],"categories":["C# #","Libraries"],"sub_categories":["C#/.NET ###"],"readme":"# MongoDB Entity Framework Core Provider\n\n[![MongoDB.EntityFrameworkCore](https://img.shields.io/nuget/v/MongoDB.EntityFrameworkCore.svg)](https://www.nuget.org/packages/MongoDB.EntityFrameworkCore/)\n\nThe MongoDB EF Core Provider requires Entity Framework Core 8 or 9 on .NET 8 or later and a MongoDB database server 5.0 or later, preferably in a transaction-enabled configuration.\n\n## Getting Started\n\n### Basic Setup\nFirst, create a DbContext with the desired entities and configuration:\n\n```csharp\ninternal class PlanetDbContext : DbContext\n{\n    public DbSet\u003cPlanet\u003e Planets { get; init; }\n\n    public static PlanetDbContext Create(IMongoDatabase database) =\u003e\n        new(new DbContextOptionsBuilder\u003cPlanetDbContext\u003e()\n            .UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)\n            .Options);\n\n    public PlanetDbContext(DbContextOptions options)\n        : base(options)\n    {\n    }\n\n    protected override void OnModelCreating(ModelBuilder modelBuilder)\n    {\n        base.OnModelCreating(modelBuilder);\n        modelBuilder.Entity\u003cPlanet\u003e().ToCollection(\"planets\");\n    }\n}\n```\n\n### Connection Options\n\n#### Option 1: Direct Database Connection\n```csharp\nvar mongoConnectionString = Environment.GetEnvironmentVariable(\"MONGODB_URI\");\nvar mongoClient = new MongoClient(mongoConnectionString);\nvar db = PlanetDbContext.Create(mongoClient.GetDatabase(\"planets\"));\ndb.Database.EnsureCreated();\nvar planet = db.Planets.FirstOrDefault(x =\u003e x.Name == \"Earth\");\n```\n\n#### Option 2: Using Dependency Injection\n```csharp\nvar mongoConnectionString = builder.Configuration.GetConnectionString(\"MongoDbUri\")!;\nbuilder.Services.AddDbContext\u003cPlanetDbContext\u003e(options =\u003e\n{\n    options.UseMongoDB(mongoConnectionString, DatabaseName);\n});\n```\n\nIf you need some more configuration, you can create the `MongoClient` and inject it into the DbContext:\n\n```csharp\nvar mongoConnectionString = builder.Configuration.GetConnectionString(\"MongoDbUri\")!;\nvar mongoUrl = new MongoUrl(mongoConnectionString);\nvar mongoClient = new MongoClient(mongoUrl);\nbuilder.Services.AddSingleton\u003cIMongoClient\u003e(mongoClient);\nbuilder.Services.AddDbContext\u003cPlanetDbContext\u003e((provider, options) =\u003e\n{\n    var client = provider.GetRequiredService\u003cIMongoClient\u003e();\n    options.UseMongoDB(client, DatabaseName);\n});\n```\n\nLater on, simply inject `PlanetDbContext` where it's needed and continue as you would normally.\n\n## Supported Features\n\nEntity Framework Core and MongoDB have a wide variety of features. This provider supports a subset of the functionality available in both, specifically:\n\n- Querying with `Where`, `Find`, `First`, `Single`, `OrderBy`, `ThenBy`, `Skip`, `Take` etc.\n- Vector search with the `VectorSearch` extension method on DbSet and fluent vector index configuration\n- Top-level aggregate `Any`, `Count`, `LongCount`, `Sum`, `Min`, `Max`, `Average`, `All`\n- Mapping properties to BSON elements using `[Column]` or `[BsonElement]` attributes or `HasElementName(\"name\")` method\n- Mapping entities to collections via `[Table(\"name\")]`,  `ToCollection(\"name\")` or by convention from the DbSet property name\n- Single or composite keys of standard types including string, `Guid` and `ObjectId` etc.\n- Properties with typical CLR types (`int`, `string`, `Guid`, `decimal`, `DateOnly` etc.) \u0026 MongoDB types (`ObjectId`, `Decimal128`)\n- Properties that are arrays, lists, dictionaries (string keys) of simple CLR types including binary `byte[]`\n- Owned entities (aka value types, sub-documents, embedded documents) both directly and in collection properties\n- `BsonIgnore`, `BsonId`, `BsonDateTimeOptions`, `BsonElement`, `BsonRepresentation` and `BsonRequired` support\n- Storage type configuration through EF ValueConverters or BSON representation attributes and fluent APIs\n- Query and update logging of MQL (sensitive logging must be enabled)\n- `EnsureCreated` \u0026 `EnsureDeleted` to ensure collections and the database created at app start-up\n- Optimistic concurrency support through `IsConcurrencyToken`/`ConcurrencyCheckAttribute` \u0026 `IsRowVersion`/`TimestampAttribute`\n- AutoTransactional `SaveChanges` \u0026 `SaveChangesAsync` - all changes committed or rolled-back together\n- `CamelCaseElementNameConvention` for helping map Pascal-cased C# properties to camel-cased BSON elements\n- Type discriminators including `OfType\u003cT\u003e` and `Where(e =\u003e e is T)`\n- Support for EF shadow properties and EF.Proxy for navigation traversal\n- [Client Side Field Level Encryption](https://www.mongodb.com/docs/manual/core/csfle/quick-start/) and [Queryable Encryption](https://www.mongodb.com/docs/manual/core/queryable-encryption/) compatibility\n\n## Limitations\n\nA number of Entity Framework Core features are not currently supported but planned for future release. If you require use of these facilities\nin the mean-time consider using the existing [MongoDB C# Driver's](https://github.com/mongodb/mongo-csharp-driver) LINQ provider which may support them.\n\n### Planned for future releases\n\n- Select projections with client-side operations\n- GroupBy operations\n- Includes/joins\n- Geospatial\n- Atlas search\n- ExecuteUpdate \u0026 ExecuteDelete bulk operations (EF 9 only)\n\n### Not supported, out-of-scope features\n\n- Keyless entity types\n- Migrations\n- Database-first \u0026 model-first\n- Document (table) splitting\n- Temporal tables\n- Timeseries\n- GridFS\n\n## Breaking changes\n\nThis project's version-numbers are aligned with Entity Framework Core and as-such we can not use the semver convention of constraining breaking changes solely to major version numbers. Please keep an eye on our [Breaking Changes](/BREAKING-CHANGES.md) document before upgrading to a new version of this provider.\n\n## Documentation\n\n- [MongoDB](https://www.mongodb.com/docs)\n- [EF Core Provider Guide](https://www.mongodb.com/docs/entity-framework/current/)\n- [EF Core Provider API Docs](https://mongodb.github.io/mongo-efcore-provider/8.2.0/api/index.html)\n\n## Questions/Bug Reports\n\n- [Forums](https://www.mongodb.com/community/forums/)\n- [Jira](https://jira.mongodb.org/projects/EF/)\n\nIf you've identified a security vulnerability in a driver or any other MongoDB project, please report it according to the [instructions here](https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report).\n\n## Contributing\n\nPlease see our [guidelines](CONTRIBUTING.md) for contributing to the driver.\n\nThank you to [everyone](https://github.com/mongodb/mongo-efcore-provider/graphs/contributors) who has contributed to this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-efcore-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fmongo-efcore-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-efcore-provider/lists"}