简体   繁体   中英

MVVMLight, Silverlight, Entity Framework

I have created

a) a basic application MVVMLight framework.

b) another project in the same solution having an Entity Model (NorthwindModel.edmx).

c) a WCF service to retrieve data through the entity model.

Now I want to link a, b, and c together. How do the project mentioned in a) above interact with the other two? How can I display/bind the data using the edmx in the View of the MVVM? Do I have to write code in the ViewModel class/classes to achieve this?

I browsed through many websites, checked many questions here on SO, but none seems to throw any light for me in this regard. The examples that I saw involved a lot of coding in the ViewModel class. If that's the only way to go about it, then why do people say MVVM with Silverlight requires very little coding?

You can use WCF RIA Services to bridge the gap between ASP.NET and Silverlight.

Get Started - WCF RIA Services

You will need to create a Silverlight library project, add entity files as link to the project. This will enable you to use the Entities in your Silverlight application.

how to add files as link

Actually you need a Web project where you host your webservices, then you need your business logic layer and data access layer where you retrieve data, then you need the entities and a silverlight entities project. After this you create your Silverlight project and add web service reference to it and thats it, now you are ready to use MVVM.

I think you could use this to refer how to build a solution with multiple projects and also have entity framework with WCF RIA services.

To ensure you project is running MVVM light you could use Nuget to inject the necessary files into your client project. Information on this is available here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM