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
|
Hi guys, I'm using names like entity, attribute, update for my database tables. They make perfect sense for my purpose, succintly describe what I'm building. However, this becomes a problem once I put them into the LightSpeed model as these names are used as part of LightSpeed's object model. Now, I could go and change the database once again to suit LightSpeed, but what I would like to find out is if I have an alternative, i.e. to preserve those names. Cheers Joseph |
|
|
At present this would require editing of the templates. The templates do a using Mindscape.LightSpeed; which brings names like Entity into scope. We do this to avoid cluttering the generated code with namespace qualifiers, because a lot of people *do* like to look at generated code and this greatly improves readability. The downside, however, is that it prevents you from using LightSpeed class names as your entity names. In order to disambiguate your names from the LightSpeed names in the generated code, you'd need to go into the templates, remove our using statement, and qualify each reference to the LightSpeed classes in the template code. We can talk you through this if required. Note that the name Attribute clashes with the System namespace, not the LightSpeed namespace, so you'd also need to remove that using directive. But this will cause you grief when you come to refer to Attribute entities in your application code, because you'll have to disambiguate it in your app code or removing using System; from your app code files (and I don't care what Resharper says, removing using System; from files you plan to edit is counterproductive). So I'd avoid the name Attribute anyway. You can of course change your entity class names without changing your database names. You can do this by editing the entity name and setting the Table Name, or more conveniently by right-clicking the offending entity and choosing Refactor > Rename (the benefit of this is that it updates references elsewhere in your code, though if your code isn't building because of ambiguities then this may not work). However I'm guessing that you really don't want to change your class names either, in which case the template solution is the only one. |
|
|
In the end, I changed those offending tables' name. If I do edit the template, would it incur the overhead of having to back it up then diff it each time I install a new build? I live on the nightly build now. |
|
|
We recommend making templates per-project so that (a) you don't need to back them up when you reinstall and (b) they can live in source control with the project so that everything still works when you bring on another dev or work on a different machine or the Win7 upgrade flattens your machine because of a poxy fraction-of-a-second brownout-- uh, anyway, there's an article on how to do this at http://www.mindscape.co.nz/blog/index.php/2009/09/16/customising-lightspeed-entity-templates/. You will have the overhead of diffing and merging, but we don't change the templates very often (famous last words) so this shouldn't be a huge thing. |
|
|
Thank you very much sir! |
|
|
Hi Ivan, I renamed all my entities yesterday and give them each a consistent prefix, e.g. Entity becomes CEntity. However, this created a problem... I can no longer "Update From Source" as the designer thinks none of these entity exist in the database, and they all need to be deleted from the model! By default, when I import the entity by dragging a table from the Server Explorer, the designer didn't fill out the Table property, and I assume that's because LightSpeed assume entity name is the same as table name. Now, if I fill out the Table property, "Update From Source" appears to be working again. This also makes me wonder about the Identity Column property as well, with the entity renamed, if LightSpeed will still figure out the right column as it's blank. Is this something quite trivial to fix? :-) Cheers Joseph |
|
|
Yes, set the Table Name on each entity and all will be well. As you say, by default LightSpeed assumes that the entity and table names are the same: Table Name is the way to override this. The identity column shouldn't be an issue unless you have renamed that as well. LightSpeed expects the identity column to be called Id. You can leave the Identity Column Name setting blank if this is the case. You only need to set Identity Column Name if the identity column is called something different (and the designer will usually do this for you if the identity column is the primary key). |
|
|
Thanks Ivan, I reckon it would be a good usability improvement for the designer to either populate those properties on import from database, or display warning message in the error list window. It may also be a time saver to be able to easily instruct LightSpeed on how to come up with default name for entities and associations. |
|
|
How about also a different icon in the LightSpeed Model window for entity that can be persisted? Perhaps also have the schema name and table name too...
For example: [E] MyEntity [E+T] MyEntityWithTable (MySchema.MyTable) |
|