none
DbDomainService<T> Doesn't generate proxy classes RRS feed

  • Question

  • I have tried this on both visual studio 2010 and 11 beta, on several machines. I have also used EF 4.3 and 5.0 - beta 2. I am trying a code first approach in silverlight 5.

    I create a DbDomainService<T> and also create CRUD operations for it, but on the client side no proxy entities are being created. I am doing this in a WCF Class Library. Here is how it is created: I add a project to the solution (WCF RIA Services class library). A client side and service side project are added automatically and linked via RIA link. I create my entities and dbcontext (see source below). I create my domain service class (the wizard only shows up half the time, very buggy as well) and make sure there are CRUD operations. I rebuild, and show all files on the client side project and there is NO GENERATED CODE. If I change the DomianService class to inherit from DomainService instead of DbDomainService<T>, then my proxy entities generate on the client side as expected.

    I get the following warning when building the solution:

    Warning 1 The following exception occurred creating the MEF composition container:
    Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    The default code generator will be used. AProgram.Client.RIAServices

    PLEASE HELP :)

    namespace AProgram.Server.RIAServices.Models.Sales
    {
    
       public class Customer
       {
          [Key]
          public int CustomerID { get; set; }
    
          [Required]
          [MaxLength(50)]
          public string CustomerName { get; set; }
       }
    
    }
    
    namespace AProgram.Server.RIAServices
    {
       public class SalesDbContext : DbContext
       {
          public DbSet<Customer> Customers { get; set; }
       }
    }
    
    namespace AProgram.Server.RIAServices
    {
       using System;
       using System.Collections.Generic;
       using System.ComponentModel;
       using System.ComponentModel.DataAnnotations;
       using System.Linq;
       using System.ServiceModel.DomainServices.Hosting;
       using System.ServiceModel.DomainServices.Server;
    
    
       // TODO: Create methods containing your application logic.
       [EnableClientAccess()]
       public class SalesDomainService : DbDomainService<SalesDbContext>
       {
          [Query(IsComposible=false)]
          public Customer GetCustomer(int id)
          {
             return this.DbContext.Customers.Find(id);
          }
       }
    }


    Phylum


    • Edited by Phylum Wednesday, May 2, 2012 3:07 AM
    Tuesday, May 1, 2012 1:11 PM

Answers

  • I found an answer for anyone that is curious. It seems that Ria Services is only compatible with EF 4.1. I found a workaround in a code project article:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="EntityFramework"
               publicKeyToken="b77a5c561934e089" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
    </runtime>

    Simply add this to your Web.config file, or if using a Ria Services Class Library, add it to the app.config and rename the app.config to web.config.

    Here is a link to the article: http://www.codeproject.com/Articles/354715/Creating-a-WCF-RIA-Services-Class-Library-for-a-Si


    Phylum


    Friday, May 4, 2012 3:57 AM

All replies