Comments (5)
Thanks for the compliment.
1 - A bidirectional relationship can be any supported cardinality. Many-to-many isn't supported in EF Core (yet) so can't work there, but does work in EF6. If you have an EF6 model where many-to-many relationships aren't working, please attach it to this chain and I'll be happy to take a look.
2 - If you're using table-per-hierarchy inheritance, Entity Framework will create a discriminator field for you... it isn't something you model in the normal sense. If you have a case where you have an odd need to model it yourself, it can be added in the DbContext's setup in the OnModelCreatingImpl
partial method.
Does that help?
from efdesigner.
Hi. i am using EF core and according to this doc it does support it.
http://www.entityframeworktutorial.net/efcore/configure-many-to-many-relationship-in-ef-core.aspx
in fact EF6 and other generators do exactly what the doc suggests to do manually.
regarding the descriminatot field, i've been adding it manually, but would be nice to have all this in a visual tool. makes life easier.
thanks for sharing.
from efdesigner.
Apologies if I wasn't as clear as I could have been. Yes, you can mimic a many-to-many association in EF Core; in fact, the doc you cite talks about that:
In the Entity Framework 6.x or prior, EF API used to create the joining table for many-to-many relationships. We need not to create a joining entity for a joining table (however, we can of course create a joining entity explicitly in EF 6).
In Entity Framework Core, this has not been implemented yet.
So, as you've pointed out, to implement this one creates two one-to-many associations from the classes in question to a "join class" containing the identity properties of the other classes. But that's not object modeling -- it's working around a deficit in the EF Core implementation that prevents you from doing true many-to-many associations, like you would do them in EF 6.
The principle behind the modeling tool is object modeling, not focusing on the database implementation. Since the implementation won't (yet) do the work it needs to do to implement that association type, there's code to restrict the ability to add a many-to-many association in the model if the type is EF Core. When EF Core evolves to the point where that's implemented, that restriction will be removed. That's not to say you can't create the artificial join class yourself ... it's just that, since it's not a true many-to-many association, the designer won't do it. (That being said, there are some convenience properties that nod to the fact that there's a database somewhere back there, like the connection string and database column name, but those don't really hurt the model.) I had kicked around the idea of creating that join class behind the scenes, but would have to take liberties in naming the tables, since I don't want their existence to be exposed to the model UI. Since most folks are picky about that, I didn't think it was a good idea. I could, however, be convinced that I was wrong.
The inheritance discriminator is the same way. When modeling classes, you wouldn't add that implementation-dependent property. It's only necessary for table-per-hierarchy inheritance, and wouldn't be a property of the class if you weren't persisting it using that particular inheritance implementation. So we don't add the property automatically using the tooling, instead letting the persistence mechanism (i.e., Entity Framework) take care of it, and therefore don't pollute the classes with properties unnecessary for their purpose in life, which is supporting the application logic. As well, if it were added I wouldn't want it exposed to the model UI, so would have to force a name for the column and, like the join class, and that wouldn't be nice. Again with this, I might be overly cautious about this.
It's really a philosophy thing. Hope that makes sense.
from efdesigner.
@scharada , did I answer your question/concern? If so, is it ok with you to close this issue?
Thanks.
from efdesigner.
@msawczyn hey. yes you did and thank you.
from efdesigner.
Related Issues (20)
- "Add -> Property" context menu entry missing, cannot add properties to entities HOT 2
- Cant set inherited entity HOT 1
- No way to import HOT 2
- Partial classes being deleted on regeneration HOT 4
- Missing ForaignKey on 1 <-> 0..1
- How add /drag an existing model or entity to design surface HOT 1
- How to import model/tables From existing Database HOT 2
- INotifyPropertyChanged removed - Help needed HOT 1
- Toolbox Items missing/Greyed out HOT 4
- Null Reference exception in Solution Explorer context menu
- Code Generation Creating Ambiguous Constructor Signatures in Specific Inheritance Scenario
- Meaningless error when trying to drag-and-drop a dll file on diagram area
- Support for per-entity inheritance hierarchy types
- Many to many with EF core 7 HOT 1
- Upgrade entity framework visual editor to latest version, now EF Model Diagrams disabled HOT 2
- Add an Example for ModelElementExtensions.GetAll(T) Method
- Missing INotifyPropertyChanged option on entity HOT 1
- "Save as image" needs work HOT 2
- "Is Identity" field missing from properties view HOT 3
- Auto include flag on connections not working
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 efdesigner.