Comments (5)
Try using Include(character => character.Account)
.
from entityframeworkcore.
Ah sorry, I did not realize that lazy loading is not yet implemented in EFCore yet!
Unfortunately, no luck using Include(character => character.Account)
either.
Do I need to enable an option when configuring my context?
Looks like the model it's generating is correct:
Model:
EntityType: AccountData
Properties:
Id (Guid) Required PK AfterSave:Throw ValueGenerated.OnAdd 0 0 0 -1 0
EmbededList (ICollection<UserItem>) 1 1 -1 -1 -1
Username (string) 2 2 -1 -1 -1
Keys:
Id PK
Annotations:
RelationshipDiscoveryConvention:NavigationCandidates: System.Collections.Immutable.ImmutableSortedDictionary`2[System.Reflection.PropertyInfo,System.Type]
EntityType: CharacterData
Properties:
Id (Guid) Required PK AfterSave:Throw ValueGenerated.OnAdd 0 0 0 -1 0
AccountId (no field, Nullable<Guid>) Shadow FK Index 1 1 1 0 1
Name (string) 2 2 -1 -1 -1
Navigations:
Account (<Account>k__BackingField, AccountData) ToPrincipal AccountData 0 -1 2 -1 -1
Keys:
Id PK
Foreign keys:
CharacterData {'AccountId'} -> AccountData {'Id'} ToPrincipal: Account
Annotations:
RelationshipDiscoveryConvention:NavigationCandidates: System.Collections.Immutable.ImmutableSortedDictionary`2[System.Reflection.PropertyInfo,System.Type]
Annotations:
MongoDb:Database: testdb
ProductVersion: 2.1.0-preview1-27567
from entityframeworkcore.
I apologize for the delay: I was out of town over the weekend for the holiday. I'll be looking into this issue tonight when I get back to my personal PC.
In the meantime, take a look at this unit test. See if there are any obvious differences between your data model and how I've set up the sample domain, as well as the use of the Include
in the test.
from entityframeworkcore.
This should now be fixed. I was passing off my queries to the EF Core library for compilation, and it was making some assumptions about the underlying query provider that weren't holding up. Essentially, Includes get compiled to either Joins or GroupJoins with a transparent identifier, which EF Core executes client-side and then uses a projection to fix up the navigations. The metadata for EFCore-MongoDB didn't match what EF Core was expecting, so it was failing to fix up the navigations when processing the transparent identifiers. I had to completely rewrite the query compilation code for navigations in order to work around this, but it's now correctly using the $lookup operator.
Unfortunately, the current MongoDB C# driver does not yet have support for the $addFields or $mergeObjects pipeline operators (MongoDB 3.6+), so my code still has to use a transparent identifier and fix up the navigations once the results come back. This might cause unexpected behaviors in more complex queries (such as Including several layers of navigations, or including a navigation from a collection member, etc.) due to how the queries have to be rewritten in order for the transparent identifier to work. I have to explore these and make sure that the code handles them correctly, but for now simple navigation queries should load correctly.
This single Include test and this enumerable include test show navigations being loaded in a query, for reference.
Please give the latest preview build a try and let me know if you see any more issues.
from entityframeworkcore.
Tests are working: relationships are fully hydrated when using Include
.
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.