Umbraco Code First with uJet

Umbraco Code First with uJet

Wednesday, March 30, 2016

Umbraco Jet (uJet) is a Code First approach to building applications in Umbraco 7. With uJet you declare your types in code, hassle-free.

uJet is available as a NuGet package!

Working with document, media, member, and data types in Umbraco can be troublesome. Properties are referenced by name, the database and code base have to be kept in sync manually. If changes are made, they have to be carefully copied between setups. This is where uJet comes into play.

Using uJet (for Umbraco 7), document, media, member, and data types are declared in code. When the Umbraco application is fired up, the database is automatically updated to reflect the types defined in the code base. There's nothing magical going on, it just saves time and makes working with types much more manageable.

Getting started is easy. Start out by adding a reference to uJet. Then, create your document, media, member, and data types (classes), define your properties and decorate your classes using the DocumentTypeAttribute, MediaTypeAttribute, MemberTypeAttribute, or DataTypeAttribute attributes. That's all there is to it. Once your application is started, uJet will find your types and move them into Umbraco for you. If you later on add, remove or update any of your types, all you need to do is to rebuild and restart your application.

Good news everyone! uJet is now available as a NuGet package (and the source code can be downloaded at GitHub).

Built-in MVC support

If you like the Code First approach, I'm sure you'll like the MVC support built into uJet too. With uJet you're no longer bound by the RenderModel.

Have your controllers inherit from JetController, and ditch the RenderModel in favor of your own document types. All of the plumbing is taken care of for you. Head over to GitHub for some demo code.

Have fun!