Core Date Entity change issue - iphone

I am working on an iPhone app.
I have modified my data model in Core Data by adding an entity.
And now my app crashes.
I think that when doing that (changing the model) I have to remove some files and reset the data store so that things can work with my new model. But I just can't remember what exactly I need to do.
Thanks for any tip.

Answered this one just the other day! It's a common issue. You need to blow away your old database file first. Here's how to do it:
Adding new attributes in existing coredata model

Related

Navigation property in derived types

I'm new to entity framework and database design and I'm using database first approach, which in visual studio 2012 default to creating POCO classes with DbContext API. I'm trying to keep the POCO classes as lean as possible and I encountered a scenario where I want to generate two types from a single table. My problem is I want to move the navigation properties along with the foreign keys to the derived types. Does anyone know a way to solve this problem?
NOTE: I tried to post an image of what I'm trying to do but apparently I still don't have enough reputation to do that.
Edit: Thanks to whomever gave me enough reputation to post an image. The image that I'm trying to post is below.
Thanks,
Raymond
Did you ever get a solution to this? I have a similar structure. I created a super-type table in my SQL Server DB with 2 sub-type, one has a relationship to another table. EF simply set it up for me. But you should be able to do it by right-clicking on your entity and adding a new navigation item. You can then create a new Association (also by right clicking).
Regards

Core Data Recipes Question

This is just a quick question I have about Apple's core data "Recipes" project, so I don't need elaborate answers. When you edit a recipe you can also edit the type. When the type cell is pressed it presents the user with a table view populated by multiple types. How exactly were those types created? I can't seem to find an explanation in the project code or in the .xcdatamodel (I've checked everywhere, and searched it) Also, why does "RecipeType" have to be it's own entity? Why can't it just be part of the "Recipe" entity? Does that have anything do with it?
In this case RecipeType doesn't necessarily have to be its own type, but it is common practice. Using an association like this has many benefits. Say if you wanted to add more metadata per type, you could add it to the RecipeType instead of duplicating a bunch of data throughout your recipes.
It appears that these recipe types are already inserted into the SQLite database Recipes.sqlite. It doesn't appear that they used any of the code in the project to populate this database. It was most likely done using Terminal or some other GUI SQLite editor.

Update model from database - refresh one table

Is it possible to refresh only one entity in entity framework designer? Every time I refresh model from database, it refreshes all entities. The problem is that this mechanism doesn't recognize properly primary keys in views, so I have to correct it manually. Am I missing something?
No, you're not missing anything. When you update model using the GUI designer, the entire storage schema is regenerated. At least, that's how it works in Entity Framework 1.
I can't tell you if you can or can't do it, but I have one clue how to figure it out.
http://code.msdn.microsoft.com/EdmGen2
EdmGen2 contains source code and dll probably with functionalities from usual EdmGen.
Unfortunately I didn't have time to investigate this further. Hope this helps.

What's the easiest way to refresh Entity Model after adding/deleting DB fields?

Does anyone know what the esiest way to update the entity model after adding/deleting the fields in the database?
I am adding a few new fields to my database, then choose "Update Model from DB" and nothing happens. The model stays intact. Did anyone encounter the same problem?
Thanks for any feedback!
With EF that shipped for .net 3.5 I tend to follow the following steps:
Delete the connectionstring
Delete the model
Generate a new model
Build solution
This is perhaps not a very solid approach but it saves me time in the long run. In the future it is easier and more stable to do a refresh but I have gone from autogenerating my model to model-first.
I would definitely check out the EDM Generator which allows you to do a full generation of the model from scratch - Click here to go to the MSDN reference. It has saved me a lot of time and hope it will do the same for you.

iPhone Core Data Generated Model Files and Custom Code

After I've generated the interface/implementation files for entities of a model file in XCode, I've not found a way to keep any custom code (validation methods, etc...) I've added to those generated files, given the scenario where I've added an attribute to a model entity and need to re-generate the interface/implementation files. Does anyone know of a way to make this happen? I've just been doing the copy/paste shuffle, but there has to be a better way.
Assuming that you're only talking about adding methods, and not new instance variables, I'd recommend using Objective C categories to add additional behavior to your model classes. Here's a blog post along the same lines.
Use mogenerator, which uses the Generation Gap design pattern to prevent your customizations from being overwritten when the code is re-generated.