title: How do I use autofac to resolve a WCF Data Service?
body: <p>I am creating a WCF Data Service using the <a href="http://wcfdstoolkit.codeplex.com/" rel="nofollow">WCF Data Services Toolkit</a> and its whitepaper <a href="http://wcfdstoolkit.codeplex.com/releases/view/60614#DownloadId=206728" rel="nofollow">Building OData Services on Top of Existing APIs</a>. The service is being added to an existing MVC 3 website that is already configured to use the AutofacDependencyResolver. The code provided in the whitepaper for exposing the service is:</p>
  
  <pre><code>protected void Application_Start() 
  { 
    var factory = new DataServiceHostFactory();
    var serviceRoute = new ServiceRoute("odata", factory, typeof(CrmODataService));
    serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } };
    serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } };
    RouteTable.Routes.Add("odata", serviceRoute);
    ...
  }
  </code></pre>
  
  <p>Is there a simple way to modify this to resolve the service via Autofac or do I need to implement my own ServiceHostFactory?</p>