locked
WCF data to store in DB with new PK and FK RRS feed

  • Question

  • User1089207845 posted

    Hi there,

    I have a local app and a database for different number of users to store local data.  Now the users will use wcf service to upload data to server database (hosted in remote server). Here I have issue with the primary keys and Foreign Keys as its relational db.

    Any ideas ?

    Thanks

    Thursday, December 5, 2013 12:48 PM

Answers

  • User-488622176 posted

    Of  what exactly? Simply removing the PK, using Guid (uniqueidentifier in SQL) to hold an entity unique key, and assigning it in code with "Guid.NewGuid()" should do the trick. Or do I misunderstand your question?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 18, 2013 6:11 AM

All replies

  • User-417640953 posted

    Hi jr_developer,

    Thanks for posting to asp.net forum.

    According to your description, I see that you are working with WCF and Entity FrameWork. And you want users can

    post data to WCF service, then save it to the database. For this, please refer to below article which explains you how a wcf service operation that validates

    and saves the updates to a database using the Entity Framework.

    http://msdn.microsoft.com/en-us/data/jj613941.aspx

    Entity Framework supports the relational database’s one-to-many and many-to-many concepts.

    As for how to handle database relationship (fk,pk) in Entity FrameWork, please check below topic.

    http://www.codeproject.com/Articles/396822/Basic-Handling-and-Tips-of-Database-Relationships

     

    Thanks.

    Best Regards!

    Monday, December 9, 2013 10:14 AM
  • User1089207845 posted

    Thank you for reply. My question is how to reconfigure PK and FK local db data when user uploads to remote db(wcf)?

    I have local db which will be updated every 30 sec with real time values. When ever the user wishes, he should be able to upload local db data to remote db.

    Here my issues is multiple users from different locations will upload the data. Now the PK and FK are no longer same for remote db to that of local.

    Now how to reassaign FK when updating remote db.

    Monday, December 9, 2013 10:28 AM
  • User-488622176 posted

    Well ... you do not. PK's are used to assure data records are unique. If you screw with this...  You could omit the PK contraints and generate the ID's yourself (ex : guids) you can simulate auto assigned PK's

    Thursday, December 12, 2013 12:37 PM
  • User1089207845 posted

    Any examles????

    Monday, December 16, 2013 1:01 PM
  • User-488622176 posted

    Of  what exactly? Simply removing the PK, using Guid (uniqueidentifier in SQL) to hold an entity unique key, and assigning it in code with "Guid.NewGuid()" should do the trick. Or do I misunderstand your question?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 18, 2013 6:11 AM
  • User1089207845 posted

    Got it. Thank you.

    Wednesday, December 18, 2013 12:10 PM