You are here:   Forum
Register   |  Login

Forum Notice

This Forum is ARCHIVE only
For LightSwitch questions,
please use the official forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


Forums

Creating A WCF RIA Service Using Entity Framework
Last Post 26 Jul 2013 05:05 AM by admin. 48 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 1 of 3123 > >>
Author Messages
Michael WashingtonUser is Offline
Send Private Message
Posts:1023
Avatar

--
11 Jun 2011 05:34 PM
    Here are directions to create a WCF RIA Service that uses a Entity Framework database. This demonstrates a web deployed application, and the method to set the connection string for the Entity Framework class in the web.config.

    NOTE: Also see

    WCF RIA Service: Combining Two Tables

    (for an article that shows how to connect to the existing database that the LightSwitch application is using)















































    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    fishyUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:86
    Avatar

    --
    12 Jun 2011 12:25 PM
    Thanks for doing this.

    Fishy
    CiroUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:1
    Avatar

    --
    15 Jun 2011 12:26 PM
    Hi Michel!

    I follow your tips and it worked nice. I have some questions, as I'm absolutely begginer about RIA, please, be patient with me:

    1- The copy and paste tasks (App.config and Web.Config) are only necessary after publishing the solution? I didn't do this part and the code worked nice in Visual Studio environment.

    2- Is it possible to use the procedure (your tip) to access LightSwitch intrinsic tables?

    Thanks to share this tip with us.

    Best regards,

    Ciro.
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    15 Jun 2011 02:01 PM

    1- The copy and paste tasks (App.config and Web.Config) are only necessary after publishing the solution? I didn't do this part and the code worked nice in Visual Studio environment.

    2- Is it possible to use the procedure (your tip) to access LightSwitch intrinsic tables? 
      


    Thank you for the feedback.

    1) Yes but the key will not be there and the EF Class in the WCF RIA Service will use whatever values were used to create the EF class. So when the key was not found it used that connection you used when you orginally imported the tables into the EF class.

    2) Yes
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Thom CUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:1
    Avatar

    --
    26 Jun 2011 03:12 PM
    Michael,

    I appreciate your work with LightSwitch for the dev community. You continue to go above and beyond the call.

    This blog was particularly well timed as I've been struggling with creating a LS-friendly WCF RIA service for more than a week without success. There are several other blogs and tutorials about this process, all of them wrong.

    I'm having similar problems with your technique. IOW... it doesn't work.

    When I try to add WCF RIA Service as a LightSwitch data source, LightSwitch just stops at the "Choose a WCF RIA Service" dialog, presumably because it doesn't recognize a valid WCF RIA Service as being available. It's not locking up (I appreciate your warning about the time LightSwitch can take finding services), it just doesn't "see" the WCF RIA Service. I suspect this is because the Domain Service resides in a simple C# class library project.

    Some questions:
    1) The project you're using to host the Domain Service is a simple C# class library. How is LightSwitch to understand this is a WCF RIA Service?

    2) When I create the simple C# class library project, there is no App.config file created by the template. Are you adding one after the project is created?

    3) In your LinqToEntitiesDomainService, your default query is returning this.ObjectContext.vw_UserRoles. When I try this, LightSwitch will not accept the data source because the object being exposed by the WCF RIA Service's default query has no key property defined. Typically, you get around this by creating a class in the DomainService with all the return object's properties and mark the appropriate property with the [Key] attribute. Then you use a Linq query to cast the collection of entities into the new return object (with a defined key property).

    Again, I thank you for your community-oriented efforts and I hope you have some insights into the problems I'm having.

    Regards,
    Thom C.
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    26 Jun 2011 05:56 PM
    @ThomC - on the Downloads page ( http://lightswitchhelpwebsite.com/D...loads.aspx ) please download:
    ■Creating a Simple LightSwitch RIA Service (using POCO)
    ■Saving Files To File System With LightSwitch
    They both contain WCF RIA services so you can see them work.

    1) You create a reference to the project using a wizard and it inspects the class and find the service
    2) The App.config is created when you use the Wizard to connect to create the Entity Framework (EF) class
    3) Yes
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    27 Jun 2011 09:16 AM
    Probably a stupid question but I would like to add multiple tables. I still only need one Domain Service, correct? Also, do I only mark one of the
    IQueryables<>
    with the
    IsDefault=true
    or do I need to do it for each table?

    Thanks,
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    27 Jun 2011 09:25 AM
    Posted By Refracted Paladin on 27 Jun 2011 10:16 AM
    Probably a stupid question but I would like to add multiple tables. I still only need one Domain Service, correct? Also, do I only mark one of the
    IQueryables<>
    with the
    IsDefault=true
    or do I need to do it for each table?

    Thanks,
    1) Yes
    2) No

    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    27 Jun 2011 09:46 AM
    Thanks Michael,
    for clarification....
    No to "mark only one" or No to "do it for each table".
    I am assuming I only mark 1...
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    27 Jun 2011 09:59 AM
    Posted By Refracted Paladin on 27 Jun 2011 10:46 AM
    Thanks Michael,
    for clarification....
    No to "mark only one" or No to "do it for each table".
    I am assuming I only mark 1...


    Ack!

    You caught my mistake. You have to have one query markes as default that does not take any parameters for each return type (table)
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    27 Jun 2011 10:15 AM
    Got it!

    Is there any logic to splitting out a large legacy database into multiple Entity's? I am new to Entity Framework an as such unsure whether it is "acceptable" to have 60 tables in one .edmx
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    27 Jun 2011 10:22 AM
    Is there any logic to splitting out a large legacy database into multiple Entity's? I am new to Entity Framework an as such unsure whether it is "acceptable" to have 60 tables in one .edmx


    I am not an expert with EF. I mostly use Linq to SQL and it can handle hundreds of tables.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    28 Jun 2011 06:46 AM
    I am at a loss. I, believe, I have followed these directions to the letter. I even wiped the slate clean and started over but still no go. What I am getting is, at runtime, a red X in place of my data that states "Unable to load data. Please check your network connection and try again.". Any guesses as to what I am missing? For reference here is my Connection String
        <add name="ConnectEntities" connectionString="metadata=res://*/ConnectDatabase.csdl|res://*/ConnectDatabase.ssdl|res://*/ConnectDatabase.msl;provider=System.Data.SqlClient;provider connection string="data source=WWCSQL;initial catalog=Connect;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
     
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    28 Jun 2011 07:23 AM
    I am at a loss. I, believe, I have followed these directions to the letter. I even wiped the slate clean and started over but still no go.

    Please download the code samples on this site and see if they work for you.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    28 Jun 2011 07:41 AM
    Just any code sample? I don't see one specific to this post but I will try a few others. I was also able to make this work connecting straight to the same database right in the LightSwitch Project.
    Sa souvraya niende misain ye!
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    28 Jun 2011 07:48 AM
    The RIA Services POCO Sample works as expected. The Print SQL Server Reports Samlpe works except when I try and Print Invoice though now that I look at it I am guessing I need the Website Sample that looks bundled with it for that portion.
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    28 Jun 2011 07:54 AM
    Just any code sample?

    on the Downloads page ( http://lightswitchhelpwebsite.com/D...loads.aspx ) please download:
    ■Integrating Visual Studio LightSwitch Application Into An Existing Website using IFrames (DNNThingsForSaleFinal.zip)
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    28 Jun 2011 08:10 AM
    It fails trying to load the data at this part:
    var UserInRole = (from DNNUser in WorkSpace.DNNDomainServiceData.vw_UserRoles
                                      where DNNUser.Username == UserName
                                      where DNNUser.RoleName == "Administrators"
                                      select DNNUser).FirstOrDefault(); 

    With the exception of ]Underlying Provider failed to Open
    Sa souvraya niende misain ye!
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1023
    Avatar

    --
    28 Jun 2011 08:53 AM
    It fails trying to load the data at this part:

    Oh darn I forgot you have to have a DotNetNuke site to connect to. That was a bad example.

    The POCO example is the best example. That is why I did that example, it shows how the WCF RIA Services work. Any other problems and they aspecificfic configuration issues that are impossible to figure out in a forum

    And I would not be able to look at your specific example because I must turn down requests for personal assistance because I would never be able to get any other work done
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Refracted PaladinUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:9
    Avatar

    --
    28 Jun 2011 09:03 AM
    Understand completely, thanks for the help. I will continue to play around with it. If I figure it out I will post the solution here for reference.
    Sa souvraya niende misain ye!
    You are not authorized to post a reply.
    Page 1 of 3123 > >>


    Latest Microsoft Visual Studio LightSwitch Forum Threads That Have Answers

    I have a super-simple screen that has one entity an a grid (that used to work).  If I try to save, using the built-in button, I get: "An error occurred while updating the entries. See the inner exception for details." It only happens in my published Azure cloud service (not on my local machine).  I have not been able to figure out how to get the Inner Exception.  I enabled the "Enable Created/Modified Properties" and I think that it might have something to do with that.  I unchecked it and the problem still exists. I have not been able to get tracing to work (I have a separate question going on that issue) so I am trying to figure out how to get the actual error.  Any ideas on how to get the actual error would be appreciated. Thanks, Mark
    Read more...

    Hi there! After closing the AddEditScreen dialog, how can I know which button was clicked? Best regards, Ciro
    Read more...

    Hi there! How can I check if a collection has unsaved records? Best regards, Ciro
    Read more...

    I am using VS 2013 lightswitch Update 3 and successfully connecting to Oracle  tables(via both managed and unmanaged ODP.NET) I can import them read them but all data is read only. When I make a form to edit or insert. All fields become disabled. My tables are very simple. They have an INTEGER primary key with Trigger/Sequence style auto increment. I am not sure if this is relevant but I noticed when importing these INTEGER columns, I see they are imported as "decimal" type since there is no column type in oracle that maps  to integer in the .Net world. Any help will be greatly appreciated
    Read more...

    Disable detail tab scolling
    8/25/2014 10:11 AM
    In the HTML client if you have a detail screen with several tabs, the collection of tabs in the header will scroll horizontally.  Is there a way to disable this behavior or otherwise get all of the tab buttons on the screen without scrolling?
    Read more...

    1234

    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation