Breeze.js with ASP MVC5 and AngularJS

angularjs breeze entity-framework-6


I'm considering developing anASP MVC5 project (NOT a WebApi; I must continue using ASP.MVC)Breeze.js and AngularJS However, I'm having a lot of issues because the documentation for achieving this is incomplete (all new examples are made with WebApi). I managed to compile my MVC controller using the Breeze.WebApi2 package I discovered on NuGet, but I'm not sure if it truly works. I have a sneaking suspicion it's not working the way I'm expecting it to. If I visithttp://localhost/breeze/MyBreeze/MetaData I obtain the JSON object from it, which is awesome. However, if I attempt to obtain Attendees with thishttp://localhost/breeze/MyBreeze/Attendees Afterward, the only thing I receive is the SQL Query rather than the JSON data, which I assume I should receive. Am I right? DoesBreeze.WebApi2 and [BreezeController] ASP MVC5 (again, not WebApi) work with?
My MVC5 controller is shown here:

using Breeze.ContextProvider;
using Breeze.ContextProvider.EF6;
using Breeze.WebApi2;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TemplateBreezeAngularMVC5.Models;

namespace TemplateBreezeAngularMVC5.Controllers
    public class MyBreezeController : Controller
        static readonly TimeSpan RefreshRate = TimeSpan.FromMinutes(60);
        private static readonly object Locker = new object();
        static DateTime _lastRefresh = DateTime.Now; // will first clear db at Now + "RefreshRate" 
        // static DateTime lastRefresh = DateTime.MinValue; // will clear when server starts

        private readonly EFContextProvider<ConferenceContext> _contextProvider = new EFContextProvider<ConferenceContext>();

        public MyBreezeController()


        public string Metadata()
            return _contextProvider.Metadata();

        public IQueryable Attendees()
            return _contextProvider.Context.Attendees;

        public IQueryable Presentations()
            return _contextProvider.Context.Presentations;

        public IQueryable Speakers()
            return _contextProvider.Context.Speakers;

        public SaveResult SaveChanges(JObject modifications)
            return _contextProvider.SaveChanges(modifications);

Here is my very basic Angular code as well. I just want the query to succeed and provide the data, even if it fails and returns the query instead.SELECT [Extent1].[Id] AS [Id], ... but I think the MVC Controller isn't functioning properly, therefore that's why. However, here is my Angular code:

breeze.config.initializeAdapterInstance('modelLibrary', 'backingStore', true);

var myApp =
        .module('myApp', ['ngRoute', 'breeze.angular', 'breeze.directives'])
        .controller("SpeakersCtrl", function ($scope) {
            var manager = new breeze.EntityManager('/breeze/MyBreeze');

            var query = new breeze.EntityQuery.from("Speakers");
            manager.executeQuery(query).then(function (data) {
                $scope.results = data.results;
            }).fail(function (e) {

then my installed NuGet packages areAngularJS , Breeze.Client , WebApi2.EF6 , Breeze.Angular.Directives , Breeze.Angular , Breeze.Server.ContextProvider.EF6 , Breeze.Server.ContextProvider , Breeze.Server.WebApi2 , EntityFramework 6.0 , jQuery , Json.NET , Q
Additionally, I made an effort to obtain the previousHotTowel MVC4 But a lot of stuff are missing, and it was unable to make it function.

It's important to note that I want to utilize ASP MVC since my employer requires it of me and because I WILL NOT create an SPA.

6/18/2014 11:21:13 PM

Popular Answer

6/20/2014 5:33:32 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow