Search code examples
silverlightentity-frameworkef-code-firstwcf-ria-services

Ria Services : Use Entity Framework Code First Classes From Another Project


I have a solution with this structure :


ProjectName.Domain ==> contains POCO classes (EntityFramework code first classes)
ProjectName.DataAccess ==> contains DbContext and EntityFramework mapping codes.
ProjectName.Task ==> It's my bushiness layer .
ProjectName.Presnetation.MvcClient ==> It's ASP.NET MVC web client.
ProjectName.Presentation.SilverlightClient ==> It's Silverlight 5 client.
ProjectName.WCFRiaClassLibrary ==> It's layer between business logic and Silverlight client

I've decided to handle logic such as queries and CRUD operations in business logic and use ProjectName.Task in domain service class.

I can't find any sample that use EF code first approach and load entities from another project , can you please help or give me link ? because when I try to create my DomainService class without wizard I can't find generated proxy classes in silverlight client project . I'm doing something like this :

    [EnableClientAccess()]
    public class CrudService : DomainService
     {
    private readonly IEntityTask _entityTask;

    public CrudService(IEntityTask entityTask)
    {
        _entityTask = entityTask;
    }

    public IQueryable<Entity>  GetAll ()
    {
       return _entityTask.GetAll().AsQueryable();
    }
    }

Is this possible to use code first classes from another project with WCF Ria Service ?
What is wrong with my approach?


Solution

  • Defintely possible. Take a look at this question to see possible problems with wcf ria + ef
    EDIT:
    I've just written a small blog post attaching to it a functional project. You can find it here