none
The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity'

    Question

  • Hi! I've installed Entity Framework 4.1 Update 1 and try to use it in a Windows Forms project (VS2010) but System.Data.Entity.Infrastructure does not exist for .Context.cs:

    Error 1 The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)

    What is the actual problem? Should I add some reference to my project?

    Harri

    Tuesday, May 15, 2012 8:51 AM

Answers

  • Hi,

    Do you have a reference to C:\Program Files\Microsoft ADO.NET Entity Framework 4.1\Binaries\EntityFramework.dll ?

    One cannot add a reference by such a "procedure".
    If to search the internet you would find quite different advice for for EntityFramewor.dll location and if to search local disk I found a couple of dozen of system EntityFramework.dll

    After I resolved this issue and checked the location of the this dll, it was in my development machine (Windows Server 2008 R2 Datacenter, since I am developing for Sharepoint 2010):

    • C:\Program Files (x86)\Microsoft ADO.NET Entity Framework 4.1\Binaries\EntityFramework.dll

    Hi! I've installed Entity Framework 4.1 Update 1 and try to use it in a Windows Forms project (VS2010) but System.Data.Entity.Infrastructure does not exist for .Context.cs:

    Error 1 The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)

    What is the actual problem? Should I add some reference to my project?

    Harri

    So, I had the same error even before update and after it as well as more errors:

    • “type used in a using statement must be implicitly convertible to 'System.IDisposable'”
    • The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'UnintentionalCodeFirstException' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)

    Theoretically, I should have succeeded to add a reference in Visual Studio 2010 by either:

    • right-clicking on References in solution --> Add Library Package References... -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”
    • menu "Tools" --> Library Package Manager -> Add library Package reference  -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”
    • menu "Project" --> Library Package Manager -> Add library Package reference -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”

    but it gave me error:

    • "This package (or one of its dependencies) contains an init.ps1 file and needs to be installed from the Package Manager Console"

    So, I installed (really added a reference, check "References" in solution explorer) it by:

    • menu "Tools"-> Library Package Manager -->  Package Manger Console 
      and typing there:
      PM> install-package EntityFramework

    That's it. All errors disappeared.

     


    Guennadi Vanine -- Gennady Vanin -- Геннадий Ванин



    Sunday, May 20, 2012 5:35 PM

All replies

  • Hi,

    Do you have a reference to C:\Program Files\Microsoft ADO.NET Entity Framework 4.1\Binaries\EntityFramework.dll ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Tuesday, May 15, 2012 11:24 AM
  • Hi,

    Do you have a reference to C:\Program Files\Microsoft ADO.NET Entity Framework 4.1\Binaries\EntityFramework.dll ?

    One cannot add a reference by such a "procedure".
    If to search the internet you would find quite different advice for for EntityFramewor.dll location and if to search local disk I found a couple of dozen of system EntityFramework.dll

    After I resolved this issue and checked the location of the this dll, it was in my development machine (Windows Server 2008 R2 Datacenter, since I am developing for Sharepoint 2010):

    • C:\Program Files (x86)\Microsoft ADO.NET Entity Framework 4.1\Binaries\EntityFramework.dll

    Hi! I've installed Entity Framework 4.1 Update 1 and try to use it in a Windows Forms project (VS2010) but System.Data.Entity.Infrastructure does not exist for .Context.cs:

    Error 1 The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)

    What is the actual problem? Should I add some reference to my project?

    Harri

    So, I had the same error even before update and after it as well as more errors:

    • “type used in a using statement must be implicitly convertible to 'System.IDisposable'”
    • The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'UnintentionalCodeFirstException' could not be found (are you missing a using directive or an assembly reference?)
    • The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)

    Theoretically, I should have succeeded to add a reference in Visual Studio 2010 by either:

    • right-clicking on References in solution --> Add Library Package References... -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”
    • menu "Tools" --> Library Package Manager -> Add library Package reference  -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”
    • menu "Project" --> Library Package Manager -> Add library Package reference -> Select the “Online” tab --> Select the “EntityFramework” package --> Click “Install”

    but it gave me error:

    • "This package (or one of its dependencies) contains an init.ps1 file and needs to be installed from the Package Manager Console"

    So, I installed (really added a reference, check "References" in solution explorer) it by:

    • menu "Tools"-> Library Package Manager -->  Package Manger Console 
      and typing there:
      PM> install-package EntityFramework

    That's it. All errors disappeared.

     


    Guennadi Vanine -- Gennady Vanin -- Геннадий Ванин



    Sunday, May 20, 2012 5:35 PM
  • I have same problem, in VS2012, following example http://msdn.microsoft.com/en-us/data/jj206878

    PM> install-package EntityFramework

    install-package : The current environment doesn't have a solution open.

    At line:1 char:1

    + install-package EntityFramework

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : InvalidOperation: (:) [Install-Package], InvalidOperationException

    + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand

     

    Saturday, December 15, 2012 1:23 AM
  • Hi,

    As inhted by the error message, you have to create/open a solution before being able to do that as it changes the current solution. Do you have a solution open ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Saturday, December 15, 2012 2:58 PM