Add CoreData Model shows "Deprecated Feature: Transient Inverse" warning - xcode

Using Xcode 10 (iOS project), I'm updating my CoreData model based on the current Model we have and I'm getting the following warning:
"Deprecated Feature"
Transient Inverse feature requires macOS deployment target 10.4 or earlier
(the warning is on the new Model I just created)
The project compiles and runs and is an iOS project not a macOS project. At this point i've literally just created the new model not added any new entities or attributes to it.
Any pointers would be much appreciated

Check all the relationships you have.
Uncheck the option transient.
Then the message disappears.

This warning appears when one or more relationships in your Core Data model have 'Transient' property checked.
In my case this was the way to fix the problem:
Click on your warning in Issue Navigator
Xcode will guide you to your "problematic" relationship
Check properties of the relationship in Data Model Inspector (see picture above)
If everything seems ok with that relationship check the inverse part (entity that relationship is referring to)

Related

Turn off codegen for XCode CoreData model

Making CoreData model in XCode with already declared classes by myself, compiler code generated duplicates for me. How get rid of that?
In the Data Model editor, change the Codegen option in the data model inspector on the right to "Manual/none":
Sadly, as far as I know, you will have to do this for every Entity separately: there is no overall override.
You can disable all automatic code generation by setting the "tools version" for the data model file to Xcode 7.3. This won't have any other effect on the model-- there are no changes to the file format.

Refactor ViewControllers - Error : Storyboard both contain a view controller with same identifier

I am using Xcode 7.3 for a project (minimum deployment target 8.0)
I have a storyboard that is growing in size. I thought of refactoring two (2) groups of scenes into Two (2) different storyboards using Editor -> Refactor To Storyboard... then creating two storyboards with different names to 'hold' the respective refactored scenes.
It worked as expected - two new storyboards (NewStoryBoard1 & NewStoryBoard2) that 'held' the two groups of refactored scenes.
When I build the project I get this error:
Deploying Storyboard References to iOS 8.0 requires that your
storyboards do not share any view controller identifiers.
NewStoryBoard1.storyboard and NewStoryBoard2.storyboard both contain a
view controller with identifier "UIViewController-knd-7b-mzO".
I did not name the identifiers as
UIViewController-knd-7b-mzO
this seemingly was done automatically in Xcode.
My question is, why is Xcode creating two storyboard references to two different view controllers with the same identifiers?
I have a few similar Q&A threads that discuss this problem, but they have offered no solution.
How can I best fix this issue? Many thanks.
MORE INFO
After trying to refactor my selected scenes/views, I was presented with a new storyboard like this:
Zooming in:
An odd storyboard reference presented itself - despite the fact that I had already selected one ViewController on the new storyboard as my Initial ViewController.
I got the same type of storyboard reference in two of my new refactored storyboards. As a result, I received this error when I built the project:
Deploying Storyboard References to iOS 8.0 requires that your
storyboards do not share any view controller identifiers.
NewStoryBoard1.storyboard and NewStoryBoard2.storyboard both contain a
view controller with identifier "UIViewController-knd-7b-mzO".
I tried renaming the new storyboard reference (listed as "Issue" in my diagram above) but that did not resolve the error.
Please see my answer below for how I resolved the issue.
I think that I received the random UIViewController-knd-7b-mzO duplicate storyboard references that caused me my build error because:
Note: If a scene has an empty storyboard ID, the Refactor to
Storyboard command automatically generates an ugly one, such as
UIViewController-gtY-c7-gYu.
(source) https://www.raywenderlich.com/115697/ios-9-storyboards-tutorial-whats-new-in-storyboards
And I had not entered storyboard IDs for all my refactored scenes/views.
Moving on ... I managed to resolve the error issue by:
Deleting the oddly-placed storyboard reference (listed in my above question as "Issue");
Making sure that I had specified an Initial ViewController in each new storyboard; and
Making sure the Reference ID field of both 'new storyboard' references in my Main (i.e. original) storyboard were blank.
In effect, this made sense. The reference directs any calls on the refactored storyboard scenes to the new storyboard (referenced by the Storyboard field) and thus automatically presenting the respective 'new' Initial ViewControllers.
Apologies for any errors in my syntax or code references, I am new to programming.
I do hope this helps anyone who may face the same issue in future.

What's the best alternative to DropCreateDatabaseIfModelChanges (MVC3)?

I've already checked the other questions and searched in google, but I found a lot of solutions...
What is the best?
I need to Alter the table when the DataModel changes, and I need an automatic Solution (like the DropCreateDatabaseIfModelChanges does..
Thanks a lot for all replies
You can go for CodeFirst Migrations. CodeFirst Migrations. You Need EF 5 binaries.
Run the Enable-Migrations –EnableAutomaticMigrations command in Package Manager Console
Add-Migration will scaffold the next migration based on changes you have made to your model.
Update-Database will apply any pending changes to the database.
To update the Entity Framework EDMX and sync it with your DB changes you double click on the EDMX in the VS2010 Solution Explorer. This brings up the designer (Model Browser window apparently is what it’s called) with a class layout of your entities. Right click anywhere on the designer surface and you’ll see an option in the dialog to “Update Model from Database.” Click on this and you get brought into the Update Wizard where you can choose the database objects you want to Add (if new), but by default it refreshes existing objects.
One thing the wizard doesn’t seem to do is delete columns from existing objects. Probably some sort of safety mechanism, but if you deleted the column from the database, do you really want to keep it in your entity? Ah well, who knows.
It don't works well all the time. In my case I try to create nothing manually with the model editor so each time I modify my database model, I open the EDMX editor, I select all entities and I delete them then, I right click the model and I select option : Update from database.
When the object list appear, I select all table and next. It update the model.

Could not find the conceptual model type

I have two Entity Data models within a MVC3 project A and B.
I have recently added the new entity data model B to deal with some new functionality, the issue is that now the existing code has stopped working and I am getting the following error when trying to access code within entity model A.
The error message is:
Could not find the conceptual model type 'project.models.Bclass'
I do not understand why it is this new functionality has affected the current code seeing as entity model A has not change in any way. And functionality B is in a separate class and does not interfere with model A.
When the new code is removed from the project and entity model B is excluded then the code works as it should.
Here is some of the stacktrace from the error:
Exception : Could not find the conceptual model type for 'Project1.Models.CrossSession'.
Application Class - method : System.Data.Metadata.Edm.MetadataWorkspace -- GetEdmSpaceType
User : temp.user
Url : http://localhost/project1/auth/message
Stacktrace : at System.Data.Metadata.Edm.MetadataWorkspace.GetEdmSpaceType(StructuralType objectSpaceType)
at System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappings()
at System.Data.Entity.Internal.InternalContext.TryUpdateEntitySetMappingsForType(Type entityType)
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
Solution found. It appears in some cases (randomly) there is a mix up in the code generated by the entity framework. This is apparently a known bug and a fix should be coming in future releases. In the mean time the way around this is to move the efm to a separate class within the solution.
One possible explanation is that if you use the database first approach and forget to add the Entity classes, you will get this error.
i.e. (from the guide linked below)
Right click on the model’s designer surface.
From the context menu, choose Add Code Generation Item.
In the Add New Item dialog that opens, select Data from the list of installed templates types on the left.
Choose the ADO.NET DbContext Generator then click the Add
button.
I normally use Julie Lerman's guide; https://msdn.microsoft.com/en-us/library/jj206878(v=vs.113).aspx
Solved this by updating EntityFramework to the latest version (6.0)
http://nuget.org/packages/EntityFramework/.
After installing it regenerate the models and it will work ;)
I had the same problem with 2 different .edmx files in the same project.
For the first .edmx model I had used "Add Code Generation Item", for the second model I hadn't. The project was building correctly but throwing that exception on runtime.
I solved generating the .tt classes for the second .edmx model as well.
Well I just installed EF 4.1 and tried to combine DbContext with a EMDX - When I tried to pass back a view I got the same error - that's why I ended up here... I think the way around this is to separate the functionality out into separate asemblies in the solution...
This can also be resolved by generating the new edmx in visual studio 2010 so it matches the older ones... (And copying over the files it generates)
Using Visual Studio 12, the issue has still not been resolved. As an alternative workaround, I set up the second SQL data model using "old fashioned" Data Classes that pre-date entity models - they're still there and they still work. Use Add - New Item - (Data Category) - LINQ To SQL Classes, open the ServerExplorer, locate the server and database, then drag and drop it onto the data classes pane. Old school - but conveniently overcomes this highly inconvenient issue when the full functionality of entity models is not needed.
I removed the edmx models, removed the Entity package, re-install the entity 5.0 and works.
I was working with some legacy software and was not keen on upgrading EF. For me, the below setting on my newly added .edmx needed to be changed to match the .edmx that already existed in the project. My new one said "T4" and I changed it to "Legacy Object Context". I did have to delete the .tt templates that were generated previously in order to get it to build. Otherwise, the old generated files stay there and the new files are also there, causing "property already defined" errors. Thx to all the answers above that helped me figure this out!
(Properties panel, after clicking in the entity designer)

What do you bind NSArrayController's Managed Object Context to in Xcode 4?

I am trying to build an document-based application for beer reviewing that allows you to enter your notes. I have built the model in Core Data and the view in Interface Builder. Following some Xcode 3-based tutorials, I am told to connect the new NSArrayController to the managedObjectContext of File's Owner. If I try and do this in Xcode 4, a circled exclamation point comes up next to "Model Key Path" in the inspector for the NSArrayController.
I can actually load the .xib file in Interface Builder in Xcode 3, make that connection, and then build it in Xcode 4 and it runs, but every field raises a validation error.
The model has an entity named Scoresheet, which has a property named date, which is an NSDate. But if I link it to the value of an NSDatePicker and try to save it to disk, it says I have "multiple validation errors." How can that be? They are both NSDates, right? Actually, I have the same problem with bindings to everything; none of my UI objects will work with my model.
The only thing I can figure is that there is something going wrong in the connection between the File's Owner and the NSArrayController.
I haven't written any code at this point, because I'm of the understanding I shouldn't have to just to link UI fields and core data. Is it different because I am using a document-based application? (I can't get it to work in a single window app, either.)
An answer of "don't use Core Data" isn't going to be productive; I know I can just fall back on a regular data object. I would like to figure this out in the context of Core Data if possible.
TIA!
(Update: this question seems to be vexing a lot of people. I have consulted the Zarra book on Core Data, the Hillegas book on Cocoa Programming, and two O'Reilly books. They all seem to be based on Xcode 3.)
NSPersistentDocument has it's own managed object context, and you should bind the NSArrayController in your document's xib file to that managed object context.
For example, if your document class is called MyDocument, then Xcode will automatically generate a MyDocument.h / .m / .xib for you. In the .xib, the File's Owner is an instance of your MyDocument class, and you can bind the NSArrayController to this, with the binding File's Owner -> managedObjectContext.
I am running into the same problem (the CarLot example in Chapter 11 of Hillegass, right?)
The following blog entry is from a developer who wrote and maintains an extension for use with NSManagedObjects and considers this a bug in XCode 4 and has filed a report in rdar : http://danieltull.co.uk/blog/2011/04/20/xcode-4-and-creating-nsmanagedobject-subclasses/
I have a machine with XCode 3 on it, I will eventually give up beating on this in 4, create the project in XCode 3 and import it into XCode 4.
Edited to add: Adding the element in XCode 3 and linking the outlet, and then importing the project into XCode 4 works fine, it does seem that this is a bug in XCode 4. I do not get validation problems from XCode 4 doing this.

Resources