.net - Getting an error when using ObjectContext.AddObject with Entity Framework -
I'm getting an error while using the unit framework and C #.
I am trying to save any of the common unit with a line of code similar to the following:
objectContextInstance.AddObject (objectToSave.GetType (). ToString (), ObjectToSave)
The error message I get is:
The EntitySet name provided should be named with EntityContainer name, such as 'EntityContainerName.EntitySetName', or DefaultContainerName property, must be set to ObjectContext.
I do not understand this error because I have checked the unit data model and confirmed that DefaultContainerName has been set.
Can anyone provide any suggestions for troubleshooting it?
Try it out:
objectContextInstance.AddObject (objectToSave.GetType ( ) .name, objectToSave)
Type string () namespace name, which is probably not even the name of unit STT.
In addition to this, it will only work if the entity type name and EntitySet name are the same if you can not guarantee it, then you should sign an entry starting with AddTo
You can use the reflection to examine the public methods of your object context and use the same parameter as objectToSave
. (These methods are generated by the EDMX code generator and are generated by the type of matching unit for the unit set.)
Of course, this would be a bit slow - but if you do not have a heavily integrated database Maybe there will be no difference.
Comments
Post a Comment