JSONAPIdotNET / JSONAPI.NET

MIT License
102 stars 23 forks source link

Choosing the right DataSpace in EntityFrameworkMaterializer #67

Open karlguillotte opened 9 years ago

karlguillotte commented 9 years ago

This issue is related with the question I posted on StackOverflow.

I have no idea what a DataSpace does in EF. However, it seems that changing the DataSpace from a System.Data.Entity.Core.Metadata.Edm.DataSpace.CSpace to a System.Data.Entity.Core.Metadata.Edm.DataSpace.OSpace in method GetKeyNames solves my issue.

I suspect that changing it in GetEntitySetName as well might solve another issue I have: IncludeInPayload(true). I would like to do a quick test, but I can not override that method.

Thanks in advance for you inputs and comments.

SphtKr commented 9 years ago

This is tricky. The best explanation I've found so far is this one, and really it doesn't explain much. At a minimum I'll have to load up a few of my apps--all of which work with the CSpace code, and see if they also work if I switch to OSpace...but really is rather have a better understanding of the difference...we may need to try and ask some EF devs to help us explain the difference. On top of all that, this may change entirely for EF7, which gets rid of the ObjectContext API entirely...presumably exposing some other API for introspecting its mapping.

A fallback for us might also be to revert to the GetIdProperty code in ModelManager if the EF-specific code fails to determine a key. You'd lose support for compound primary keys at that point, but I'm doubtful those work at present anyway--it's not tested.