Referencing error

Topics: Data Access Application Block, Enterprise Library Core
Jul 17, 2013 at 1:23 PM

After I successfully referenced(Addess binaries from Add Reference) Data and Common libararies, upon building the project I recieve "Type 'DatabaseProviderFactory' is not defied" and "Type 'Database' is not defined."

I am using Visual Studio 2010, Enterprise Library 6.0 and SQL Server 2008 R2

This is what my code looks like
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Common.Configuration
Imports Microsoft.Practices.EnterpriseLibrary.Common

Public Class cDBServer

    Private DBFactory As DatabaseProviderFactory
    Private defaultDB As Database = DBFactory.Create("SAYACORESQL")
Any reason why is this happening? Any solutions would be appreciated.

Jul 17, 2013 at 2:11 PM
The issue occurs because Enterprise Library 6 targets .NET 4.5 while Visual Studio 2010 can only target .NET 4.0. If you want to use Enterprise Library 6 then you should use Visual Studio 2012 and target .NET 4.5. If you are using Visual Studio 2010 then you can use Enterprise Library 5.

Randy Levy
Enterprise Library support engineer
Support How-to
Marked as answer by randylevy on 10/7/2013 at 11:09 PM
Jul 17, 2013 at 2:39 PM
I moved back to EntLib 5.0 and everything works.

Thanks Randy!