Moving from LINQ to SQL to LightSpeed

LINQ to SQL has been a very popular technology with SQL Server users, providing far greater ease of use than previous Microsoft data access technologies and introducing many .NET developers to the concept of object-relational mapping. However, LINQ to SQL delivers only very basic domain modelling capabilities — no aggregates, no value objects, etc. Not to mention that it’s tightly coupled to SQL Server and that Microsoft, who are trying to encourage adoption of the Entity Framework instead, are no longer enhancing LINQ to SQL.

Figure 1. Microsoft’s roadmap for the popular LINQ to SQL framework. (Artist’s impression.)

So what if you’re hitting the limitations of LINQ to SQL and want to move on to something better? Or what if you just want to try out an alternative ORM, but don’t want to have to build a whole new model from scratch just to try it out?

First things first: this is never going to be a completely transparent process. Every ORM has different conventions for defining units of work (LINQ DataContexts), setting up configuration, and so on. Having said that, LightSpeed 3 does include a handy new feature that should cut down on the workload.

If you drag a LINQ to SQL DBML file from Solution Explorer into a LightSpeed model, we’ll load your existing LINQ classes into the LightSpeed model. Easy as that! So you can easily keep your model, including any customisations and mappings; plus now you get all the benefits of the LightSpeed designer, like database synchronisation, and can start marking up your model with LightSpeed features such as eager load aggregates.

Here’s how it looks – the original LINQ to SQL model on the left, and the LightSpeed model on the right (click for full size):

LINQ to SQL file imported into LightSpeed

A basic version of LINQ to SQL import is included in the LightSpeed 3.0 RTM. We’ve rounded out this feature a bit in the nightly builds, so if your LINQ model uses inheritance or access modifiers, you’ll want to get the updated version. As always, if you’re using a LINQ to SQL feature that the converter doesn’t handle, let us know and we’ll see what we can do.

Tagged as LightSpeed

2 Responses to “Moving from LINQ to SQL to LightSpeed”

  • Does it handle multi key entites. That would be a nice shortcut to create a linq to sql with designer multi primary key then drag it to ligthspeed as a shortcut.

  • Hmm, I haven’t tested it with composite primary keys, but it should work. Just to understand, does this mean our designer CK support is missing something that you find useful in the LINQ to SQL designer? If so, do let us know and we’ll see if we can improve it.

  • Leave a Reply


Join our mailer

You should join our newsletter! Sent monthly:

Back to Top