none
Entity Framework 6 - An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) RRS feed

  • Question

  • 've published my application to my server (iis7.5 windows server 2008 R2, asp.net4). I tried to set build to x86, x64, any cpu and it doesn't worked. I tried to allow 32bit applications through IIS and still the same result.

    The error occurred only when I try to get some data from database using entity framework 6.0.2. Everything working when I loading a static MCV page (without database calls).

    This is my error: This is my error

    Your help will be very appreciated

    • Moved by CoolDadTx Wednesday, February 26, 2014 4:53 PM EF related
    Monday, February 24, 2014 9:51 PM

Answers

  • Hello Arnold Simha,

    It seems that you have upgraded Entity Framework 5 to Entity Framework 6 with your project. Then it needs you do some changes with your project, the Entity Framework has put some class into other namespace, some are changed as below:

    System.Data.EntityException => System.Data.Entity.Core.EntityException
    
    System.Data.Objects.ObjectContext => System.Data.Entity.Core.Objects.ObjectContext
    
    System.Data.Objects.DataClasses.RelationshipManager => System.Data.Entity.Core.Objects.DataClasses.RelationshipManager

    For details, please refer to this link:

    Updating Applications to use EF6 - http://msdn.microsoft.com/en-us/data/upgradeef6

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, February 26, 2014 8:06 AM
    Moderator

All replies

  • It sounds like your code is loading the wrong database driver. What is your connection string?



    Visual C++ MVP

    Monday, February 24, 2014 11:58 PM
  • I have more explanations regarding the issue, When the sql installed on the same server of the application everything works well, but when sql sever located on different server I get this error. Sql server version is 2008.

    All my queries are linq queries and I'm using automatic entity framework connection string

    Tuesday, February 25, 2014 7:33 AM
  • The error message is indicating you are using a dataadapter to perform an update to the database.  I suspect you used a command builder which took a SQL Select statement and create three additional commands : Update, Delete, and Insert.  An update is being performed and it appear one of the fields that are being written to the database doesn't match the fields of the database.  Since an update is being performed the command is performing a ExecuteNonQuery method.

    Since it works on some machine and not others I suspect the error is in the size of an integer which on some operating systems is 32 or 64 bits.


    jdweng

    Tuesday, February 25, 2014 8:05 AM
  • I've tested the same code with Entity Framework 5 and it works.

    It's not working while using EF6

    Tuesday, February 25, 2014 9:29 AM
  • Hello Arnold Simha,

    It seems that you have upgraded Entity Framework 5 to Entity Framework 6 with your project. Then it needs you do some changes with your project, the Entity Framework has put some class into other namespace, some are changed as below:

    System.Data.EntityException => System.Data.Entity.Core.EntityException
    
    System.Data.Objects.ObjectContext => System.Data.Entity.Core.Objects.ObjectContext
    
    System.Data.Objects.DataClasses.RelationshipManager => System.Data.Entity.Core.Objects.DataClasses.RelationshipManager

    For details, please refer to this link:

    Updating Applications to use EF6 - http://msdn.microsoft.com/en-us/data/upgradeef6

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, February 26, 2014 8:06 AM
    Moderator