title: breezejs: dynamically switching between OData and WebAPI
body: <p>I'm facing a bit of a tricky situation here. I have two services that my application needs to access to. One is a pure ODATA service and the other is a WebAPI (with Breeze controller) service.</p>
  
  <p>My application is designed around the AngularJS modules and breeze is injected into two differerent single-instance services :</p>
  
  <pre><code>angular.module('domiciliations.services').
     factory('domiciliationService', function (breeze) {
  
       breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);
       //more initialization goes here
  
       //then query methods go here
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>angular.module('person.services').
     factory('personService', function (breeze) {
  
      breeze.config.initializeAdapterInstances({ "dataService": "OData" });
  
       //more initialization goes here
  
       //then query methods go here
  }
  </code></pre>
  
  <p>Now obviously the problem is that once the person service has been instanciated, the domiciliations service then uses OData because the config was overwritten. </p>
  
  <p>So, what is the general approach for tackling this issue ? Is there a way to isolate the config ? 
  So far the only way I can think of, is to call the initializeAdapterinstances method each time a query method is called, which is not really desirable.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As per Jay's recommandation I'm now using DataService. I'm having an error though in ctor.resolve at the line:</p>
  
  <pre><code>ds.jsonResultsAdapter = ds.jsonResultsAdapter || ds.adapterInstance.jsonResultsAdapter;
  </code></pre>
  
  <p>ds.adapterInstance is null, therefore this throws an exception. But I don't understand why it's null.</p>
  
  <p>Here's what I've done:</p>
  
  <pre><code>var service = new breeze.DataService({
              serviceName: 'http://localhost:16361/api/mandates',
              adapterName: 'WebApi'
          });
  var manager = new breeze.EntityManager({ dataService: service });
  
  //this is the line causing the later exception:
  
  manager.fetchMetadata().then(function () { ... }
  </code></pre>
  
  <p>Did I forget to do something ? </p>