Larry Brasfield wrote:
...
The framework opens and closes the database, presumably like it treats
other DB connections. The schema that it sets up for objects related to
each other relies on foreign keys. Unfortunately, foreign key
enforcement in SQLite, as now specified and implemented, only lasts from
the time a PRAGMA is issued to turn it on until the connection is
closed. Without some trickery, (or modifying System.Data.SQLite from
its distributed form), I see no way to hook DB opens so that I can get
foreign key enforcement turned on when it needs to be on.
There is a reasonable, if not readily obvious way to handle this problem.
The System.Data.Entity.DbContext object that must be created early in
framework use scenarios has a Database property whose Connection
property has an event called StateChange. By adding a suitable delegate
(event handler) to this event, it is possible to turn on foreign key
enforcement just after the connection is opened and before any work is
done with it.
This does not make persistence of foreign key enforcement seem much less
desirable.
--
Larry Brasfield
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users