Import any CSV File into Umbraco with the Umbraco LINQPad Driver

Published 23/07/2016 - Updated 02/08/2023

A profile picture of Gary Lewis Cheetham, the author of this article

Written by

Gary Lewis Cheetham

Automotive marketing specialist from Manchester, UK

I’ve recently successfully imported data from a large CSV file into Umbraco using Shannon Deminick’s useful Umbraco LINQPad driver. Here’s a high-level overview of how I did it:

You can import any valid CSV file through this process, and infact, it would work with any data format parseable in .NET – LINQPad provides a full scriptable .NET environment.

Setting up LINQPad

You’ll need to install the Umbraco LINQPad driver so that your local LINQPad can connect to your Umbraco installation. Note that you can only connect to a local Umbraco installation, not a copy running on a remote server. You’ll have to deploy your data using an Umbraco package.

  1. Download and install LINQPad from http://www.linqpad.net/.
  2. Download UmbracoLinqPad.lpx from GitHub.

Now, you should be able to follow Shannon’s documentation to get LINQPad setup (taken from the README.md in the GitHub repository)

  • In LinqPad, Click “Add Connection”
  • Click “View more drivers”
  • Select “Browse”
  • Add the UmbracoLinqPad.lpx file that you’ve downloaded
  • Choose your Umbraco installation root folder

LinqPAD should then have a connection available for your local Umbraco installation, as shown in the screenshot above.

Writing the Import Script

You’ll have to write a little custom .NET code in LINQPad to take your CSV file and create the content nodes in Umbraco using the Umbraco API (specifically the content service).

LINQPad provides a full scriptable .NET environment for you to play with. If you’ve ever done this kind of thing in .NET or worked with LINQPad before, you should be able to improvise.

Though I can’t provide a one-size-fits-all solution here, here’s a little example code to get you started. Playing with code and your particular CSV file’s schema should yield some quick results for you.

Make sure the “language” is set to “C# Program” in the dropdown list at the top of the editor in LINQPad. This will enable you to write a full program instead of a single C# statement inside LINQPad.

Deploying from your local Umbraco to a live environment

Now, because LINQPad can’t connect to a live Umbraco environment, you’ll have to deploy the new content nodes you’ve created to your live environment manually. I did this with a package.

  1. Open your local Umbraco backoffice. Expand Developer > Packages
  2. Right-click on “Created Packages” and click “Create Package”. Fill in the package meta-data like Name, Version, License, etc. (There are required fields)
  3. Select the content nodes you’d like to deploy in the right-hand pane.
  • Make sure you include any document types the new content nodes depend on when you’re creating the package.
  1. Click “save”, and then click “publish”
  2. A download link will now be available in the “Package Properties” tab. Download the package and remember where you left it.

Installing the package on the server

This should be as easy as installing any other package.

  1. Go to the backoffice in your live environment and expand Developer > Packages
  2. Click on “Install Local Package” and follow the on-screen instructions

Conclusion

This process is very flexible and has allowed me to import a diverse range of information into Umbraco. There are some drawbacks, however:

Umbraco LINQPad driver has Certain Limitations

The Umbraco LINQPad driver is very handy, but certain parts of the Umbraco API depend on a WebContext and HTTP/Web Server environment which the LINQPad driver cannot provide.

The Umbraco Packaging Process is Slow and Unreliable with Large Amounts of Data

I think my package was on the brink of being too big, because the package install and content publish process took aaages. I did think it started hanging at one point and refreshed the screen, but the install and publish process relies on the browser session not being refreshed halfway through.

Thanks for reading! If you enjoyed this post and would like to get in touch, find me on twitter @glcheetham.

Expert advice

You're reading the GL Digital blog, where auto marketing experts share proven tactics to grow your dealership.

Struggling to make good video?

Sometimes it feels like posting on TikTok is a waste of time.

Build a powerful local brand and watch customers roll in from TikTok.

About the author

A profile picture of Gary Lewis Cheetham, the founder of GL Digital Automotive Marketing, smiling outside a car dealership

Gary Lewis Cheetham is an automotive marketing specialist, born and raised in Oldham, Greater Manchester. Gary Lewis Cheetham is the founder of GL Digital Automotive Marketing. He spent his teenage years working at the family dealership after school, learning the ropes of the car trade from the inside out.

After moving on to working in marketing, Gary Lewis founded GL Digital in 2020 when he noticed a need for direct-to-consumer marketing platforms within the auto industry. He now strives every day to help independent dealers in the UK and US realise their potential. Gary also loves Formula 1 and motorsport.