Sunday, April 12, 2015

MVVM Part 1

In the previous blog entry we created a simple database and a WPF project skeleton. Now we will start looking at a trivial MVVM design to display a single row in the database.

I mentioned before that I would use Framework Entity to provide our Model. Here are the steps to do that.

    1. Right click on the project, select Add -> Add New Item
    2. Select Data in the left panel, then select ADO.Net Entity Data Model in the right panel.
    3. Rename model1 to MVVM_Walkthrough_Model and click [Add]
    4. In the Entity Data Model Wizard select EF Designer from Database and click [Next>]
    5. Click [New Connection]
    6. Select SQL Server or SQL Server Express and click [Continue]
    7. Type localhost as the Server Name (or where ever your database is)
    8. Under Select or Enter a database name, select MVVM_Walkthrough and click [OK]
    9. Back at the wizard, click [Next>]
   10. Chose an Entity Framework version (any of them will work in the walkthrough)
   11. Under "Chose your Database Objects and Settings", select the Config table as shown below.
   12. Click [Finish]



You have now created an EDMX file which will provide the model of your config table. You can reference this model as MVVM_WalkthroughEntities and we will do so very soon.

Now we have defined our Model. We will define the ViewModel in part 2.

No comments:

Post a Comment