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 all, I've successfully migrated from 1.x to LS 2, and everything is working great. I'd love to start using the designer, but I can't seem to import existing classes. Is there a way to import existing Models into Second, there are several methods that perform checking and logic within the Model to both validate as well as create display strings for our web interface. Will the designer overwrite existing code when it generates the attributes and property accessors?
Thanks, Todd |
|
|
There is an experimental command-line tool, lsgetmodel, in the Tools directory, which will examine a (compiled) assembly and generate a .lsmodel file for the entities in that assembly. You can then import that .lsmodel file into your project. This won't overwrite your existing code, but it will conflict with it. The designer generates a separate code file, XxxModel.lsmodel.cs / XxxModel.lsmodel.vb, containing class, field and property declarations for all the entities defined in the graphical model. Therefore if you already have a class called, say, Customer, and you also have a designer entity called Customer (and assuming everything is in the same namespace), you'll get a compiler error that there are two Customer classes. The classes generated by the designer are marked partial, so you can combine these two classes into one by adding the partial modifier to your existing Customer class. But now you will get errors that the _name field and Name property are defined twice. For simple properties/associations where you have no custom logic, you can delete these members out of your handwritten class. For complex properties/associations where you have handwritten business logic, you can change the Generate option to None, so that the designer won't generate "dumb" code to conflict with your smart code. Of course you could just set Generate=None on absolutely everything, which would save you figuring out which properties are safe to hand over to the generator and which are not, and just leave everything to your existing code. If your model is fairly large, this could get a bit dreary: if so, you could either post-process the XML to add generateOnly="None" to each property, or let me know and I'll add an option to lsgetmodel to do it for you. (Note: I think some kinds of association don't yet support Generate=None but hopefully that won't be a major issue.) That way you can keep all your existing code. Finally, you will also need to check things like attribute markup e.g. if you have ColumnAttribute or TableAttribute or validation attributes in your class definitions you will want to make sure that they are not duplicated. Please note that lsgetmodel is an experimental tool and has not been extensively tested. So you may run into bugs or problems. There are also some limitations in what it recognises: it was written initially to support database mapping stuff, so non-database-affecting things like caching and some validations may not come across. Again, happy to fix anything that affects lots of classes or properties, but for things that only affect one or two classes or properties, you'll probably just have to fix them up by hand. Also, lsgetmodel does not create a diagram layout. So when you load the .lsmodel into the designer it will be a rat's nest. You can use Auto Arrange to try to pick it apart but Auto Arrange is pretty dumb and you will probably still have some manual work to do to make it look sensible! |
|