I have a need to clone existing entity and insert it as a new object to the database.
Can somebody please advise a best way accomplish this?
I used detachEntity method of a breeze for the object I wanted to clone. However that left navigation property blank. I did not went through further research and wrote a generic code to manually copy the navigation properties to cloned object.
Cloned object then added to the breeze manager using createEnttiy and that did the job.
Related
I'm pretty new to MVC. I've built an EDMX, successfully created the models and am now trying to go through scaffolding to build a controller. The first thing I notice is that in the Model Class dropdown, I have duplicates:
Now, "BillysRentals2" is the name of the project. I don't know where those extras are coming from or where these "Model classes" are stored. It's true I've had to re-do the adding of the ADO.NET Entity thing several times, but even after I completely delete the EDMX and all its contents, some of those model classes still remain, so which are the real ones and where are the others hiding? It's confusing when you create "Model" and you're seeing "Model1" and stuff popping up.
But the second problem is that once I select a class, and press OK, I get this beautiful gem:
And yes, I tried removing the EDMX completely, doing a Re-build, removing and re-adding connections, Rebuilding again, and I'm still getting that message. What's wrong? I'm sure the fact that I'm getting multiple entries above means that there are bits and pieces of my previous efforts lying around someplace that are confusing MVC (not that it's hard to do) but how do I find them and get rid of them to start over?
And P.S. what is the difference anyway between a model class and a data context class?
I had several metadata files leftover from the last time, which had field names that I didn't import this time around.
The template comes without database at first. When I launch the application some code must create the db obviously, because I check the appData folder and now it's there.
Can you tell me which part of the code creates it? Thanks. I have long looked at the code and I cannot figure it out.
I think the only answer possible is that entity framework creates the database automatically. But the strange thing is if I remove thee database it does not get recreated, I get an error that says it's missing it.
I have a model Version. The entity passPhrase of Version needs to be migrated to New entity passPhrase in Home model.
But the Home model is introduced in new version of database. It was not present in old xcdatamodel. How can I migrate data from
Version.passPhrase to Home.passPhrase
And the golden rule of CoreData migration is - avoid custom migration at any cost. :)
So the way to do this to use lightweight migration to add your new entity, and then just use a one off migration script to move your data over.
You can remove the passPhrase property from your Version class definition but you need to leave it in the model for now so you can still access the old data. This can be cleaned up at some time in the future when you are confident all of your users have upgraded to the newer version, or just leave it there forever.
To access the existing value during your copy just use [version valueForKey:#"passPhrase"] and then once copied clear it out the same way [version setValue:nil forKey:#"passPhrase"]
In core data, Changing Entity / Model mapping does not comes under light weight migration. You have to handle it manually by subclassing NSMigrationManager and implementing custom NSEntityMigrationPolicy.
Apple provides little documentation on the subject.Please check the Custom Core data migration with detailed example. Hope this will help.
I'm using Spree's 3-0 Stable Backend. I know that Master Variant get created after a new product gets created, but I cannot find the file/code where the Master Variant code gets triggered.
The resource controller had pretty generic create code and a redirect to the Product's url. Does anyone know where/how the Master Variant gets created?
Anddd, I found my own answer after posting. Funny how that works out.
For anyone in the future searching this, you have to look inside of the core gem rather than the backend. Variants get created after a Product gets created if the "option_values_hash" exists, which triggers the "build_variants_from_option_values_hash" method.
"Options_values_hash" and "build_variants_from_option_values_hash" can both be found at "spree/core/app/models/spree/product.rb ".
I have some code (Forms/Frames) in the repository, is there anyway to disable the 'use' option. I only want objects in the repository to be 'inherited' or copied.
And is there a way to set the default to be 'inherited'
Have looked at the XML in the RADStudioRepository.xml and there is no obvious fields to add/edit.
Thanks
There has indeed never been a way to specify in the object repository for a form or frame to be "inherit only".
Not in the current RADStudioRepository.xml way of specifying what is in the object repository, nor in the old way (I forgot the config name back in the Delphi 2..7 days).
What you can do is suggest this as a new feature for a future Delphi version at http://qc.embarcadero.com
I think it is an interesting feature request, and would upvote such a request. So let us know if you create such a request.