This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I created a database for "QUARTZ.NET" in SQL Server 2008 and then tried to import it into LightSpeed designer by simply dragging the respective tables from the Server Explorer to the LS design surface. It seems to do a much better job than EF, especially how it renames models and so forth. However none of the foreign keys (a.k.a. relationships) are imported. I scanned the documentation and forum and didn't find any references to indicate that this isn't supported. Am I doing something incorrect? Thanks, Werner |
|
|
Normally foreign keys are materialised as one-to-many associations (the FK columns don't appear as properties on the entity surface, because they're implicit in the associations, but they're there). However, it seems that all the foreign keys in the Quartz schema are composite keys which overlap the primary key, and to be honest LightSpeed doesn't handle this scenario at all well. LightSpeed needs to represent the foreign key as an entity field (which can be composite field), and therefore requires significant intervention to handle the case where the foreign key overlaps or is contained in the Id field. The designer is unable to automatically create relationships in this case, and special code is required to implement them (and even with this special code there are some limitations on what you can do with them, e.g. eager load, cascade delete). See http://www.mindscapehq.com/documentation/lightspeed/Working-with-Legacy-Databases/Using-Composite-Keys#_Toc297195246 for some pointers and http://www.mindscapehq.com/forums/Thread.aspx?ThreadID=2653&PageIndex=2 for an example. (On an unrelated but happier note, if you haven't already spotted it, the model properties contains a Strip Table Prefix option which you can use to have us infer names like Calendar and Trigger instead of QrtzCalendar and QrtzTrigger -- if you so wish of course!) |
|
|
Thanks Ivan, your explanation clears it up. I do like the way it cleans up the database schema when its imported. Its so much better than EF. Well done. Is there any support to run SQL scripts as part of the migration? Having worked with SQL Server and MySQL, I understand that each one has its own implementation to run scripts. For example, with MySQL, one can use the MySqlScript class. It would be convient if LS could provide a high level way of executing scripts without having to resort to another framework. Thanks, Werner |
|
|
In a migration, you can call ExecuteNativeCommand to execute arbitrary SQL. This doesn't provide all the facilities of the MySqlScript class (e.g. async callbacks) but it should serve for most requirements. |
|
|
Thanks, that works for me. |
|