LightSpeed 2 includes a designer which you can use to create your domain models visually by dragging and dropping. As you update the model, LightSpeed automatically generates the entities as C# or Visual Basic code.
However, the entity code is only one half of the equation. What about the database side of things? To help you keep your database and your model in sync, the LightSpeed designer includes a feature called “schema round-tripping,” which enables you to update your model to match your database schema, or update your database schema to match your model.
For example, suppose you’re designing a Product entity, and you add a Description attribute. Without schema round-tripping, you would go into a separate database design tool (such as SQL Server Management Studio or MySQL Administrator) to add a column to the Products table in the database. Using the LightSpeed designer, however, you can right-click the Product shape and choose Update Database. LightSpeed determines that the Description attribute doesn’t have a corresponding database column, and offers to create one:
If you’re happy that this is the right change, LightSpeed applies it:
Schema round-tripping works in both directions: if you had added the Description attribute to your database first, you could have chosen Update From Source, and LightSpeed would have offered to add it to your model. So you can design in a data-centric way or an object-centric way, whichever you feel most comfortable with.
Schema round-tripping can help you with the following changes:
The full feature set is available on SQL Server, Oracle and PostgreSQL. There are currently some limitations in MySQL and SQLite support. If you run into these limitations, though, don’t forget that you can instead make changes through your database tools and use Update From Source to get them into LightSpeed. Alternatively, if you do prefer to design model-first, you can use the Update Database dialog as a checklist, even if you have to make the changes manually.
To get schema round-tripping to work, you need to tell LightSpeed which database to synchronise against. You can set this up manually by clicking on the designer background and configuring the provider and connection string in the Properties window. LightSpeed will automatically configure the database if you drag a table from Server Explorer (and the model doesn’t already have synchronisation set up). One gotcha is that, in order to match up entities with database tables, LightSpeed needs to know whether you are using the convention that table names are pluralised or not (that is, should it look for a Person table or a People table). If you find that LightSpeed keeps offering to create a Person table when the database already contains a perfectly good People table, click the designer background, go to Properties and check the pluralisation setting.
Schema round-tripping isn’t a 100% synchronisation. For example, it doesn’t currently detect if the length of a text field is out of sync between the database and the model. Nor does it have the facilities of a production-quality database designer. For example, it doesn’t generate SQL scripts that can be saved and run in your other environments, and in the 2.0 release it doesn’t have great support for bulk updates such as adding multiple tables with relationships between them all in one go. It’s aimed at enabling you to rapidly make small, frequent, iterative changes — adding and removing attributes or relationships, adding new entities, changing data types — and thereby to speed up your development cycle. Within those limitations, however, it will help you more rapidly prototype, prove, evolve and test your domain model.
Schema round-tripping is included in all editions of LightSpeed, including the free Express edition.