Page 13

Quick look - Add indexes to tables with Entity Framework 6.1 Beta 1

At the time of writing, beta 1 of Entity Framework 6.1 has recently been released. This is mostly a maintenance release , however, there are several new feature of note, including the ability to add indexes using a new data annotation when developing using the code first approach. Add indexes using the Index attribute To add an index, simply add the Index attribute as required; A quick look in SQL Server Management studio reveals that the index has been added for us. The key created was non…

Continue reading

Create custom C# attributes

You have probably added various attributes to your ASP .NET MVC applications, desktop applications, or basically any software you have developed using C# recently. Attributes allow you to provide meta data to the consuming code, but have you ever created and consumed your own attributes? This very quick tutorial shows how to create your own attribute, apply it to your classes, and then read out its value. Sample Project To demonstrate this concept, I have created a Console application and added…

Continue reading

Use T4 Templates to create enumerations from your database lookup tables

T4 (Text Template Transformation Toolkit) has been around for a while now… its been a part of Visual Studio since the 2005 release . In case you don’t know, T4 can be used to automatically generate files based on templates. You create a text template, which is then transformed (interpreted) by Visual Studio into a working file. T4 can be used to create C# code files, and indeed it forms the basis of the current scaffolding templates you have probably used when creating ASP .NET web applications…

Continue reading

Publish your website to an IIS staging environment using Microsoft Web Deploy

One of the simplest and quickest ways to publish your website to a staging environment is, at least in my opinion, using Microsoft Web Deploy . This post is about how you approach this, a future article will discuss why you probably shouldn’t do this . Key points; The remote server should be running Internet Information Services (IIS) 7.0 or later. You can use the Microsoft Web Platform Installer to install all the extra bits you need to make this work. You need to set appropriate…

Continue reading

Resilient Connection for Entity Framework 6

Disclaimer : I cannot take a shred of credit for the code you are about to see. I simply went over to the Entity Framework source code repository on CodePlex , copied some code, butchered it, hammered it, and rolled it until it fitted nicely into the slot that was my requirements. Please direct your thanks to the Entity Framework team . I had a requirement whereby I needed a resilient Entity Framework connection, and by that I mean a connection that could retry a certain number of times…

Continue reading