Search code examples
.netasp.net-mvcvb.netdbcontexthangfire

Hangfire DbContext Not Working


I'm trying to set up Hangfire for the first time and running into problems. No doubt my development environment is partly to blame. I am using VB 2010, SQL 2005 and .NET Framework 4.0. I've installed a bunch of packages to get this far with Hangfire, including EntityFramework.

This is the code that has me stumped. It is located in the Models folder of my MVC project.

Imports System.Data
Imports System.Data.Entity


Namespace Hangfire.Models

    Public Class HangfireDbContext
        Inherits DbContext

        Public Sub New()
            MyBase.New("HangfireDb")
        End Sub

    End Class

End Namespace

Notice that I have an Imports statement for System.Data.Entity. The .NET 4.0 version of System.Data.Entity.dll is included in my project references. However, the compiler complains that type 'DbContext' is not defined!


Solution

  • Based on further research, DbContext was introduced in version 4.1 of System.Data.Entity under .NET Framework! Missed it by that much ><.

    Evidently, there is no way to easily get VS2010 to use anything after version 4.0 of .NET Framework. It looks like I'm screwed until I spring for a newer version of VS.