简体   繁体   中英

Trouble with BreezeJS and Entity Framework 6

It appears that the Breeze EFContextProvider is trying to use System.Data.Objects.ObjectContext, which has apparently been moved (see EF 6 System.Data.Objects.ObjectContext Error ).

Anyone know how to solve this problem?

This is the error I get returned to the browser from the Metadata action method.

{
    * 
$id: "1",

    * 
$type: "System.Web.Http.HttpError, System.Web.Http",

    * 
Message: "An error has occurred.",

    * 
ExceptionMessage: "Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.",

    * 
ExceptionType: "System.MissingMethodException",

    * 
StackTrace: " at Breeze.WebApi.EFContextProvider`1.GetCsdlFromDbContext(Object context) at Breeze.WebApi.EFContextProvider`1.BuildJsonMetadata() at Breeze.WebApi.ContextProvider.Metadata() at App.Spa.Controllers.BreezeController.Metadata() in ...filepath...\BreezeController.cs:line 23 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4() at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"


}

EF 6 is still in Alpha. We probably won't try to support it for Breeze until it at least makes Beta. But you have access to the source via Git, so this specific issue should be pretty easy to fix by changing the source per the post you mentioned.

this is what i tried:

  1. download breeze-master from the github and extract it,
  2. open the Breeze.*.sln with visual studio 2012, update EF6 (remove old EF if exists) using Nuget Manager Package,
  3. you will see some EF namespace referred in breeze-master source were underlined as reference error, to correct them, follow the Update namespace instructions mentioned at

    http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6

  4. rebuild the entire solution and new Breeze.WebApi.dll is created

  5. open your project and add reference to that Breeze.WebApi.dll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM