LINQ to SQL to Entity Framework conversion template

Many customers have asked us how to port a LINQ to SQL application to the Entity Framework. In order to make this process easier, we have developed a metadata conversion template.

This template converts LINQ to SQL metadata (.dbml) to metadata compatible with Entity Framework (.edmx). While not a complete solution to the conversion problem, it is a useful first step. The template available for download is still in the development stage, and any feedback you have on the user experience, additional features, or any other aspect of the conversion would be greatly appreciated.

The T4 template is intended to convert simple valid .dbml files to .edmx files. All of the basic elements of the .dbml file are mapped to their .edmx counterparts. For instance, Tables are mapped to EntitySets and Types are mapped to EntityTypes. Additionally, stored procedures (including customized insert, update and delete stored procedures) and associations are also converted.

Downloading the Metadata Conversion Template

Included in the zip file is a .vsix installer for the T4 Conversion Template. Also included is detailed documentation for the template. VS 2010 Beta 1 is required.

Download the Template


Two walkthroughs have been written to help guide users through the conversion process. The walkthroughs both take the form of unit tests which can be run against the existing LINQ to SQL metadata and the Entity Framework metadata produced by the conversion template. Each walkthrough contains detailed instructions on how to convert the existing LINQ to SQL project to Entity Framework using the Conversion Template. The first is the Widget Factory walkthrough, which shows a basic conversion. The second (CustomCUD) shows how to convert a LINQ to SQL project which uses custom insert, update and delete stored procedures. The walkthroughs are available individually.

Widget Factory Walkthrough

Custom CUD Walkthrough

Caveats and Known Issues

Because the Conversion Template is still under development, there are a number of open issues and unimplemented features. A more comprehensive list can be found in the documentation included with the template installer.

· Inheritance: Inheritance has not been fully implemented. While the template may work in some basic cases, this aspect of the conversion remains an open issue.

· Independent Associations: Foreign-key associations will not be available until .NET 4.0 Beta 2, so the current version of the template will only work with the "UseIndependentAssociations" flag set to true.

· Property Attributes: not all of the property attributes (such as "Unicode" and "FixedLength") are converted because these are not explicitly present in the .dbml file.


We are interested to hear any comments you have about known issues, additional feature requests, suggestions for additional walkthroughs or any other aspect of the conversion process.

Christina Ilvento
Entity Framework Team

Comments (12)

  1. App says:

    Until the EF supports all the functions of Linq-To-Sql any conversion is going to be problematic.  Simple DateTime functions that worked just fine in Linq-To-Sql are all broken in EF.  Please can you prioritize getting EF to be a superset of Linq-To-Sql higher than this conversion code.  Many of us can create the metadata simply be re-importing our database but we can’t easily make up for the lack of missing functionality.

  2. I concur with App. Re-importing the DB seems to be far easier, but people graduating to EF from Linq2Sql are usually left with a whole bunch of lost functionality.

  3. Klaus Enevoldsen says:

    Unless there is a conversion tool for the code that uses the Linq 2 Sql diagram, then a conversion template is useless. In other words I agree with App and Robert McLaws…

  4. Christina Ilvento says:

    Thank you for taking the time to look at the new metadata conversion template.

    As was suggested, you could create metadata for an EF project by re-importing the database used by the original LINQ to SQL project, but there are several scenarios in which we think the conversion template will be helpful. First, if there has been any change to the dbml which does not exactly correspond to the database, these changes will be lost. Second, the EF conventions for naming and relationships are significantly different.

    This metadata conversion template is the first of a set of tools we are considering to help you convert existing LINQ to SQL application code to EF. As the EF continues to incorporate more of the features available in LINQ to SQL, we plan to adapt the tools use this increased functionality.

    As always, thanks for your feedback!


  5. shawn says:

    +1 for making EF a superset of Linq2Sql.  Support for enums is one particular problem area.

  6. Flores says:

    When I follow the installation instructions it fails with the message "The extension manifest is invalid". using beta 2. Does this template only work in beta 1?

  7. JRob says:

    Is there any update to this now that 2010 has been released?

  8. joe says:

    Any updates? Would be great to get a converter that can work off of a LinqToSql xml file only, rather then the dbml. I use sqlmetal to generate the xml and code separately.

  9. simmdan says:

    While there has been some interest, so far the interest has not been enough to justify further investment in this project rather than other efforts such as adding more core features to the EF.  If that changes in the future, we’ll be sure to post back here.

    – Danny

  10. George says:

    Sometimes developers' attitude really amazes me. More a I read responses from devs like this, more I want to give up on .NET.

  11. Bill says:

    Any update on this conversion tool?

  12. Julian says:

    I disagree with some of the commenters above. Having a DBML to EDMX converter would be an excellent thing to have and a worthwhile investment of Microsoft's time. I have a very large Linq-to-SQL codebase that I need to move to EF and re-generation from the database doesn't work because there are many specific class name and field name mappings that get lost. A conversion function would help us all move to the (now) more feature-rich EF.

Skip to main content