Foreign key support in SQLite3

眉间皱痕 提交于 2019-11-30 09:31:43

问题


According to this thread from 2010, an "EnforceFKConstraints" connection string property was supposed to be implemented into future releases of SQLite. Does anyone know if the developers have gotten around to doing that?

If not, is there another way I can enable foreign key support without doing "PRAGMA foreign_keys = ON" on each connection? I need this to make sure that deletes always cascade.


回答1:


Future development of System.Data.SQLite ADO.NET provider for SQLite is done by this group. The project is currently in migration status and some features are even unavailable now (which were available in 1.0.66 version, which is last maintained by Robert Simpson (original library author)).

According to latest source code available in trunk "EnforceFKConstraints" is not supported. However there is foreign keys connection string property which have default value of False, maybe it does the job? Try including foreign keys=True property in your connection string. Be sure to use latest stable build from here.

Update. After looking deeper in source, I'm almost sure that this connection string property is doing exactly that you want.



来源:https://stackoverflow.com/questions/6288871/foreign-key-support-in-sqlite3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!