locked
Domain Service reference RRS feed

  • Question

  • I created a separate Model layer containing the Ado.Net entity model. Then referred this from a seaparte service layer .I tried creating a Domain Service class I got all the class names listed there. But "Generate associated classes for meatadata option is disabled".Can anyone help on this ?

    Saturday, January 29, 2011 1:28 AM

Answers

  • This is what I've been trying to say.  You CAN seperate the service and the model.  It's the code generation tooling in Visual Studio which isn't smart enough to work with multiple projects.  So you can seperate everything you want, you just have to do it by hand instead of having the help of Visual Studio.

    What you can't seperate is the Metadata from the Model.  The way RIA Services works is you have to attribute a partial class of your Model with the metadata for that model.  And the only way you can work with partial classes is if every definition of the partial class is in the same project.

    Example:

    Project 1:
      Models (edmx if using Entity Framework)
      Metadata

    Project 2:
      DomainService

    Project 3:
      Website
      References Domain Service

    Project 4:
      Silverlight Application
      Reference Domain Service project, which generates client-side classes which are decoupled from the server. 


    This is a valid and supported scenario, which I've done before.

    Wednesday, February 2, 2011 12:37 PM

All replies

  • Try not to separate out the services, because the advantage of RIA services might be lost.

    Saturday, January 29, 2011 10:20 AM
  • Just to clarify a bit for you.  The way that the Metadata works is it uses partial classes.  So the metadata and the original class file have to be in the same project for that to work.  This is because you can't define one part of a partial class in a different project.  So you can have your Domain Service in a different project, but the Metadata needs to be in the same project as your Model.

    Hope that helps.

    Joe

    Saturday, January 29, 2011 12:50 PM
  • Hi Xamlcoder,

    I am not trying to separate the metadata to another layer but trying to separate the Model and service into separate layers.

    Thanks,

    Thani

    Sunday, January 30, 2011 12:17 PM
  • Right, though the code generation is not smart enough to work with multiple projects.  So you'll only get the option to generate the Metadata if you create the service class in the same project as the model.  What I've done in the past is create the service class in the same project as the model, that way I get the generated Metadata.  However I then move the service class to a different project.

    Monday, January 31, 2011 11:08 AM
  • I don't understand... Creating an EntityModel in a Model class to be reffered to by a service?  It should be other way around, but doesn't have to be, I just don't understand why it would be done this way...

    You can put the EntityModel anywhere I guess, but you don't have to do that in fact one-time one-place is best.  Decide the one place where the entity model should go and put it there, then repost to this forum the exact error you are getting...I believe the other poster was telling you that if you put the EntityModel at the appilcation layer you don't need the associated classes... 

    Monday, January 31, 2011 10:35 PM
  • I don't understand... Creating an EntityModel in a Model class to be reffered to by a service?  It should be other way around, but doesn't have to be, I just don't understand why it would be done this way...

    You can put the EntityModel anywhere I guess, but you don't have to do that in fact one-time one-place is best.  Decide the one place where the entity model should go and put it there, then repost to this forum the exact error you are getting...I believe the other poster was telling you that if you put the EntityModel at the appilcation layer you don't need the associated classes... 

    Monday, January 31, 2011 10:43 PM
  • Actually I am trying to separate the DataAccess and Service into separate layers. But seems DomainService is written to mix all of them into one single layer. Then I wont go with DomainService. Its a very bad idea creating a Storng coupling between the DB and UI. So I would prefer to add a WCF service instead of going with DomainService.

    Wednesday, February 2, 2011 12:10 PM
  • This is what I've been trying to say.  You CAN seperate the service and the model.  It's the code generation tooling in Visual Studio which isn't smart enough to work with multiple projects.  So you can seperate everything you want, you just have to do it by hand instead of having the help of Visual Studio.

    What you can't seperate is the Metadata from the Model.  The way RIA Services works is you have to attribute a partial class of your Model with the metadata for that model.  And the only way you can work with partial classes is if every definition of the partial class is in the same project.

    Example:

    Project 1:
      Models (edmx if using Entity Framework)
      Metadata

    Project 2:
      DomainService

    Project 3:
      Website
      References Domain Service

    Project 4:
      Silverlight Application
      Reference Domain Service project, which generates client-side classes which are decoupled from the server. 


    This is a valid and supported scenario, which I've done before.

    Wednesday, February 2, 2011 12:37 PM
  • Thanks XAML coder. You really helped to come at a conclusion.

    Wednesday, February 2, 2011 10:54 PM