Comments (6)
It's already in the works! I've started a documentation branch for adding all of the relevant XML docs to the code as well for consumption with Intellisense.
from entityframeworkcore.
The first two wiki entries have been created:
https://github.com/crhairr/EntityFrameworkCore.MongoDb/wiki/Getting-Started
from entityframeworkcore.
Great - the use of attributes looks slightly strange in a EF Core context, in particular this:
[MongoDatabase("zooDb")] - could the UseMongoDb method be extended with a second parameters for the database name?
from entityframeworkcore.
Not currently, but you can configure the database in OnModelCreating (essentially what the attribute is doing):
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
new InternalModelBuilder(modelBuilder.Model.AsModel())
.MongoDb(ConfigurationSource.Explicit)
.FromDatabase("zooDb");
}
This is quite clunky since Microsoft decided to split their builders into public and internal versions where the InternalModelBuilder
takes a Model instead of an IMutableModel
for some unobvious reason. This is why I prefer the attribute. I will probably end up adding a property to the options extension since that would be more concise than the above. But I think that anybody already familiar with the MongoDb C# driver would also prefer the straight-forward, declarative, aspect-oriented style of the attributes.
FWIF, the Bson* attributes are what the driver uses to create its BsonClassMap
mappings, so I've implemented conventions to support those to make it easier for people already familiar with the driver to adopt this provider. I do intend at some point to add conventions to the adapter to support attributes used by EF Core (like Key
and DatabaseGenerated
) so that a BsonClassMap
can be created from a "standard" EF Core model.
from entityframeworkcore.
This is fantastic! Can you tell me if there is built in support for accessing the .aggregate functionality for mongoDb?
I'v been spending months evaluating a completely different tech stack, (Meteor) and I've hit a dead end regarding aggregate usage while also using angular 2. (Long story)
from entityframeworkcore.
EDIT: this project wraps the MongoDB C# Driver, and DbSet<T>
is essentially implemented as mongoDatabase.GetCollection<T>.AsQueryable<T>()
. Anything that you can do with their Linq provider, you can do with a linq query using EFCore-MongoDB.
But, if you need more than that and must use the aggregation framework directly, read on...
END EDIT
It's possible, but there's currently no direct support for it through EFCore-MongoDB. I plan to expose this a bit more fluidly using extension methods on DbSet<T>
. In the meantime, you should be able to use the MongoDB C# driver's aggregation framework by injecting an IMongoDbConnection
into your class constructor and using it something like this:
public IEnumerable<T> AggregateTheThings<T>()
{
var pipeline = new AggregateArgs()
{
/*do your thing here*/
};
return _mongoDbConnection
.GetCollection<T>
.Aggregate(pipeline);
}
You can find some examples of using the driver's Aggregate method here: http://mikaelkoskinen.net/post/mongodb-aggregation-framework-examples-in-c.
Note: you might encounter some issues if your collection contains polymorphic documents. Be sure to supply the base document type to GetCollection<T>
. I already have a fix for this that will ensure that the correct collection for a polymorphic subtype is always returned, which will be committed in the next few days as part of an Identity provider for MongoDB.
from entityframeworkcore.
Related Issues (20)
- Support for complex property HOT 1
- How can I use dotnet ef dbcontext scaffold HOT 1
- Multiple DbCntexts select query can't work concurrently. HOT 13
- Self refrence read not support HOT 3
- DbSet.Find throws InvalidOperationException HOT 2
- dbContext.DBSet.FirstOrDefault(e => e.FirstName == "xx") missing filter in MongoQueryable HOT 5
- bug: can not modify child HOT 7
- self refrence still can not work HOT 1
- Does this work with IdentityServer4 ? HOT 1
- MissingMethodException in Blueshift.EntityFrameworkCore.MongoDB.Metadata.Conventions.MongoDbRegisterKnownTypesConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder) when using EF Core 2.2 HOT 2
- Wiki Getting Started Installing EFCore-MongoDb error HOT 1
- .NETCore 3 Preview 4 MongoDB.Driver needs upgrade HOT 2
- Still i got this Efcore internal classes problem HOT 1
- Get ObjectDisposedException when execute same query on differend DbContext instances
- Method not found exception
- Entity Framework 3.0 support? HOT 3
- What is the status of tis project? HOT 1
- Hangs on UseMongoDb HOT 2
- Missing Implementation for method HOT 1
- Missing Implementation for method 'get_Info' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframeworkcore.