Unable to See the Model Classes While Adding a New Domain Service

Ever came across a situation where you want to add a new domain service class to your RIA Service solution & you don’t see the class names from your model?

UPDATE

According to a Tweet from Colin Blair you can also add the RiaServices.EntityFramework NuGet package to your project to fix this issue. 

https://twitter.com/ColinBlair/status/328927765871079426

The problem

The problem can be recreated by the following:

  1. Ensure your have a primary key defined in your table
  2. Create a new Silverlight Project, enable RIA services
  3. On the server side add a new Data Model then rebuild the solution
  4. Click on "Add" -> "New Item" -> "Domain Service class"
  5. You see a new "Add Domain Service Class" window but the classes from your model do not show up for use.

    empty.PNG
     

The Solution

The Solution is:

  1. Open your Model (.edmx file) in Model Designer (just double-click)
  2. Right-click in an empty space within the Model Designer & choose "Properties"
  3. Change the value of "Code generation strategy" from "None" to "Default"

    PropertiesWindow.PNG
     
  4. Select the Server Project Name (for example MyExample.Web) & click on the "Show All files" button on:

    showAllfiles.PNG

     
  5. Expand the "model.edmx" file & locate & delete the 2 .tt files.

    ttFiles.PNG
     
  6. Rebuild the solution
  7. Now click on "Add" -> "New" -> "Domain Service"

Pooff!! This time you will see the classes available in the Add Domain Service Class window.

filled.PNG

Hope this helps some poor soul out there like me.

http://www.supreet-tare.com/
http://www.taritas.com/