fir
fir

Reputation: 387

What wrong with my Core Data model?

I am a kinda new in CoreData and can't understand what wrong with my model. The error occurs when I am trying to add persistent store to store coordinator:

NSPersistentStore *persistentStore = [self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:error];

Here is a log and error:

> CoreData: sql: CREATE TABLE ZMANAGEDOBJECT ( Z_PK INTEGER PRIMARY KEY,
> Z_ENT INTEGER, Z_OPT INTEGER, ZSECTION.ARTICLES INTEGER, ZTITLE
> INTEGER, ZBOOK.AUTHOR INTEGER, ZNAME INTEGER, ZAUTHOR INTEGER,
> ZPUBLISHER INTEGER, ZSUBTITLE INTEGER, ZTITLE1 INTEGER, ZAUTHOR1
> INTEGER, ZTEXT INTEGER, ZTITLE2 INTEGER, Z_FOK_SECTION.ARTICLES
> INTEGER, ZCREATEDAT TIMESTAMP, ZUPDATEDAT TIMESTAMP, ZID_ VARCHAR,
> ZTYPE BLOB, ZCONTENT BLOB, ZATTRIBUTES BLOB, ZCOVER BLOB, ZIMAGE BLOB
> )

> CoreData: annotation: Disconnecting from sqlite database due to an
> error.

> CoreData: error: (1) I/O error for database at
> /Users/firuznarzikulov/Library/Application
> Support/BahaiAppAdmin/BahaiAppAdmin.sqlite

Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be
opened." UserInfo={NSSQLiteErrorDomain=1, NSUnderlyingException=I/O
error for database at /Users/user/Library/Application
Support/App/database.sqlite. SQLite error code:1,
'near ".": syntax error'}

And here is my model graph: enter image description here

ManagedObject is abstract entity and also it is a parent for all other entities except LocalizedString.

I appreciate any help and ideas!

Upvotes: 1

Views: 591

Answers (1)

DDP
DDP

Reputation: 2563

Try renaming your relationships without "."s.

The usual pattern is e.g. "authorName" for a to-one relationship and "authorNames" for a to-many relationship.

Upvotes: 4

Related Questions