locked
How to use ado.net entity framework in silverlight 2? RRS feed

  • Question

  • How to use ado.net entity framework in silverlight 2,please?

    Can I connect to database with ado.net entity framework,like windows client ?

    Thursday, June 26, 2008 12:45 AM

Answers

  •  

    Thank you,SteveWong.It's a good article.But I have a question:

    In that example,ADO.NET Data Service have already generated Customer class,but it is needed to generate Customer class by hand in silverlight client ,how to resolve this?

    No you do not generated those Customer class by hand in Siverlight side. Once you add ServiceReference to your Silverlight project,  the proxy class is generated, all the objects that are marked as DataContract and exposed by the WCF service in the Server side will be available to you at Siverlight side. So you can just access them by using something like:  YourWebService.Customer. 

     


     

    Thursday, June 26, 2008 11:00 AM

All replies

  • Thank you,SteveWong.It's a good article.But I have a question:

    In that example,ADO.NET Data Service have already generated Customer class,but it is needed to generate Customer class by hand in silverlight client ,how to resolve this?

    Thursday, June 26, 2008 10:14 AM
  • On my own, I will generate the same class in Silverlight

    Similar problem is the WCFService and Silverlight when WCFService send a list of userdefined class to Silverlight, Silverlight should have the same class in order to manipulate the data. In that case, we also have to create the same class again in Silverlight.

    I dont know if it make sense. Please dont hesitate to tell me if there does have any problems

    Thursday, June 26, 2008 10:44 AM
  • Hey

    so far there is no way to directly access a database in silverlight. (and it probably wont be implemented either)

    So you have to generate a class with data service utils to do crud operations on a database with silverlight.

     

    Btw: Please feel free to contact me directly, as i just went through that process so i might be able to give you a hint or something like that...

    Thursday, June 26, 2008 10:57 AM
  •  

    Thank you,SteveWong.It's a good article.But I have a question:

    In that example,ADO.NET Data Service have already generated Customer class,but it is needed to generate Customer class by hand in silverlight client ,how to resolve this?

    No you do not generated those Customer class by hand in Siverlight side. Once you add ServiceReference to your Silverlight project,  the proxy class is generated, all the objects that are marked as DataContract and exposed by the WCF service in the Server side will be available to you at Siverlight side. So you can just access them by using something like:  YourWebService.Customer. 

     


     

    Thursday, June 26, 2008 11:00 AM
  • Really in that case? sladapter?
    We can access the class? Surprise

    I have just done lots of useless stuff to create all the class again in Silverlight, poor me

    Thursday, June 26, 2008 11:41 AM
  • Yes, I do that all the time. Unless in test case when I put a data structure in Silverlight just for a quick test. All my real data objects are defined in the Service side. Because my business objects behind my all my Service will use them as well.

     

     

    Thursday, June 26, 2008 11:45 AM
  • "Once you add ServiceReference to your Silverlight project,  the proxy class is generated"

    May I program to generate the proxy class ,please? How to do this?

    Thursday, June 26, 2008 9:36 PM
  • Sorry. I meant if you are using Entity Model + WCF service. Like the sample in this link:

    http://silverlight.net/learn/tutorials/sqldatagrid.aspx

    I have not fully explored the ADO.Net DataService yet. I did read Michael Sync's blog and he's creating customer class again in Silverlight side. I don't know if that's the only way. Because if we can do it in WCF service, why not ADO.Net DataService which I believe is using WCF service (maybe I'm wrong here)? But I have to play it more to make sure.

     

     

    Thursday, June 26, 2008 10:09 PM
  • You can run the utility DataSvcUtil.exe which resides in the %windir%\microsoft.net\framework\v3.5 folder and it will generate the proxy classes for you to use in your silverlight application. For further questions about ado.net data services in silverlight , pleases try the astoria forums at : http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1430&SiteID=1

    Sunday, June 29, 2008 2:47 AM
  • "Once you add ServiceReference to your Silverlight project,  the proxy class is generated"

    May I program to generate the proxy class ,please? How to do this?

     

    OK, I did some reaserch on this subject. I found how to do this. At this point, it's not that straightforward. 

    Currently we can not even add Service Reference for ADO.Net DataService.  But hopefully when we get final release of either (or both) Silverlight and ADO.NET DataService we should be able to do this just like what I said in my first post ("just add a Service Reference should generate the proxy class").

    But you can still manually generate the proxy class at this point as Phanatic pointed out. Read the following blog. It shows you how to consume DataService in Silverlight 2.

    http://www.shawn-wildermuth.net/2008/06/06/Using_ADO_NET_Data_Services_in_Silverlight_2_Beta_2.aspx

     

     

    Tuesday, July 1, 2008 5:36 PM
  • Hi There,

    In the latest RC0 its fantastic . We can just refer the Service and it generates all the stubs for us. No need of proxy generators.

    Thanks 

    Monday, September 29, 2008 11:30 PM
  • Hi!

    I installed VS 2008 SP1 then Silverlight 2, and Entity is not supported!

    Does someone have the same issue?

    Saturday, June 20, 2009 11:17 PM
  • Hi There,

     You should definitely get the Entity framework. That will not appear in the silverlight project. Only in the ASP.Net project for attaching silverlight you can see them. Right clikc the web project or site  then add the ADO.Net entity framework. Then you can use the WCF service or the ADO.Net Entity Framework to expose them as service.

     If you are doing this for learning please go and have a look at the RIA service and Silverlight 3. There you can expose any classes as RIA services and just use them as you refer in the web application.

    http://msdn.microsoft.com/en-us/magazine/dd695920.aspx

    Thanks,

    Thanigainathan.S

    Monday, June 29, 2009 8:25 AM
  • Hi,

    I was using custom serialization which doesnot require DataContract or DataMember attributes on my model classes and hence i did not require to add the class as a KnownType in the service contract. This will not generate the client side proxy for my class.

    The solution that I followed was to "Add as Link" the model class on the server project to my client silverlight project. So effectively only one version of the class exists and what ever changes we make in it will be reflected on both client and server projects.

    Thanks

    Jac

    Monday, June 29, 2009 8:55 AM
  • take a look at WCF RIA Services

    Wednesday, February 24, 2010 4:38 AM
  • I am planning to silverlight and entity model for my site. But my website uses database on high scale and its user interface is really very rich. Please see  indiabazaaronline.com .Is it good to use silverlight and EDMX for this high data centric web based website. Can anybody suggest ?

    Monday, February 28, 2011 4:47 AM