将MySQL模式作为CoreData数据模型导入Xcode [英] Importing a MySQL schema to Xcode as a CoreData Data Model
问题描述
我有一个现有的MySQL数据库,我想将模式导入Xcode并创建一个核心数据数据模型。
I have an existing MySQL database, I would like to import the schema into Xcode and create a Core Data data model.
是否有一种方法(工具,过程)导入 CREATE
语句所以我不必手动建立模型?
Is there a way (tool, process) to import the CREATE
statements so I don't have to build the models "by hand"?
作为一个中间步骤,我可以转换为SQLite,我不担心关系,外国键等只是自动生成实体
(表)和属性
(列)。
As an intermediary step I could convert to SQLite, I'm not worried about the relationships, foreign keys etc just auto-generating the Entities
(Tables) and Properties
(Columns).
推荐答案
实际上,我需要的功能太严重了,我决定做一个OSX实用程序这样做。 但 ...然后我在Mac Appstore中找到一个实用程序(部分)解决这个问题(它是免费的一段时间,我不知道它的当前状态)。它称为 JSONModeler 和它所做的是解析一个json树,并自动生成coredata模型和所有派生的NSManagedObject子类。因此,典型的工作流程为:
Actually I needed the feature so badly too that I have decided to make an OSX utility to do so. BUT... then I found a utility in the Mac Appstore that (partially) solves this problem (it was free for some time, I do not know its current state). Its called JSONModeler and what it does is parsing a json tree and generates the coredata model and all derived NSManagedObject subclasses automatically. So a typical workflow would be:
- 将表从MySQL导出到xml
- 转换xml to json
- 使用该json提供实用程序并获取您的coredata模型
一个更复杂的场景(关系等)我想你必须调整你的XML,所以它会反映一个有效的对象树。然后JSONModeler将能够重建该树并将其导出为coredata。
Now, for a more complicated scenario (relationships etc) I guess you would have to tweak your xml so it would reflect a valid object tree. Then JSONModeler will be able to recreate that tree and export it for coredata.
这篇关于将MySQL模式作为CoreData数据模型导入Xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!