Print Page | Close Window

Test with objectcontext

Printed From: IdeaBlade
Category: Breeze
Forum Name: Community Forum
Forum Discription: Build rich JavaScript apps using techniques you already know
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3636
Printed Date: 28-Mar-2024 at 9:03am


Topic: Test with objectcontext
Posted By: pierom
Subject: Test with objectcontext
Date Posted: 19-Sep-2012 at 1:40am
Following your documents I am testing breeze with a database first object context.
I reference entityframework 5.0 with target net 4.0 while the objectcontext is enclosed in a library with EF 4.0 dlls.
Running the metadata request from url I get the error: 

Public Class GareController
    Inherits ApiController

    Private contextProvider As Breeze.WebApi.EFContextProvider(Of dbGare.GAREEntities) = New Breeze.WebApi.EFContextProvider(Of dbGare.GAREEntities)("Gare")

    <AcceptVerbs("GET")> _
    Public Function Metadata() As String
        Return contextProvider.Metadata
    End Function

    <AcceptVerbs("GET")> _
    Public Function MA_PS2_CONFIG() As IQueryable(Of dbGare.MA_PS2_CONFIG)
        Return contextProvider.Context.MA_PS2_CONFIG
    End Function

    <AcceptVerbs("POST")> _
    Public Function SaveChanges(ByVal saveBundle As JObject) As SaveResult
        Return contextProvider.SaveChanges(saveBundle)
    End Function

End Class

The error is:
Could not load file or assembly 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)





Replies:
Posted By: pierom
Date Posted: 19-Sep-2012 at 9:26am
An update:

From the Github source I noticed that webapi.dll is compiled against EF 4.3.1.
Using nuget I installed EF 4.3.1 and now it is working.


Posted By: jtraband
Date Posted: 19-Sep-2012 at 6:11pm
We are considering compiling the Breeze.WebApi with EF 5 ( actually EF 4.4 for .NET 4, but the nuget download actually makes it look like EF 5).  We need to also offer the 4.3.1 version because MS moved some of the DataAnnotations across namespaces between EF 4.31 and EF 4.4 and we don't want to break 'legacy' EF 4.3.1 apps.  So we will likely offer two versions of the Breeze.WebApi in one of our next releases.  Hope this helps.


Posted By: rmja
Date Posted: 23-Sep-2012 at 10:58am
If you:
  1. pull the source from github
  2. open it in VS2012
  3. change the .net target version to 4.5
  4. remove the entity framework from nuget
  5. install entity framework 5.0
  6. build
then you have a working dll for a 5.0 project.


Posted By: jtraband
Date Posted: 25-Sep-2012 at 1:05pm
Thanks, we fixed this in version 0.57 ( and higher).  The Breeze.webApi.dll as shipped is now compiled against EF 5 and .NET 4.0.  Note that the actual version of EF 5 for .NET 4 is actually "4.4", so this is what we are actually compiling against. 

If you are running .NET 4.5 this should still work but if you want you can recompile the Breeze.webApi project to use the .NET 4.5 version of EF 5 using the technique mentioned above.

We also documented this in "EF versions" section  of the docs at

 http://www.breezejs.com/documentation/web-api-configuration 



Print Page | Close Window