问题描述
我想在我的核心数据中导入数据库模式,我是基于视图的应用程序和核心数据手动添加。
我创建了一个新的数据模型,现在我想要导入我在.sql文件中获得的数据库模式,是否可以导入该模式或我需要手动创建所有表?
请注意,Core Data是一个对象图表持久化框架,而不是一个数据库本身。
虽然Core Data可以通过sqlite存储来支持,但对于大部分,实现细节是不透明的。在任何情况下,您将无法将 sql
备份到Core Data模型。
我的建议您决定核心数据是否是适合您的框架,在这种情况下,您应该通过在模型构建工具或中创建实体和关系,或者如果您热衷于保留数据库模式,然后查看原始sqlite周围的Cocoa包装器,例如Gus Mueller的
查看。在常见问题中的是这个Q / A:
I want to import database schema in my core data, i am a view based application and core data added manually.
I created a new data model , now i want to import database schema which i got in .sql file, is it possible to import that schema or I need to create all tables manually?
Note that Core Data is an object graph persistence framework rather than a database per se. It may be subtle distinction but an important one when you consider trying to do something like what you are proposing.
While Core Data can be backed by a sqlite store, for the most part, the implementation details are opaque. In any case you won't be able to back-port your sql
to a Core Data model.
My recommendation is for you to decide whether Core Data is the right framework for you, in which case you should work with it by creating your entities and relationships in the model builder tool or alternatively, if you are keen on keeping your database schema, then looking at Cocoa wrappers around raw sqlite, such as Gus Mueller's FMDB
Take a look at the Core Data Programming Guide. Among the FAQ's is this Q/A:
这篇关于如何在核心数据中导入数据库模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!