Building an Enterprise App with WPF, MVVM, and Entity Framework

After you’ve started to build your first enterprise app with WPF, MVVM, and Entity Framework, some questions like these might pop up:

  • how to structure my Solution?
  • how to set up and use Entity Framework?
  • how to structure Views and ViewModels?
  • how to communicate between ViewModels?
  • how to load and save entities
  • how long should I keep Entity Framework’s DbContext alive?
  • how to validate user input?
  • how to work with many-to-many relationships?
  • how to create a tabbed user interfaces?
  • how to handle conflicts when multiple users are using my application?
  • how to define a modern look for my application?

Last week my latest course was released on Pluralsight that answers all of these questions (and a lot more :)). You can watch it here:

Building an Enterprise App with WPF, MVVM, and Entity Framework Code First

This course teaches you everything you need to know to build a solid enterprise application with WPF that uses MVVM and that connects to a SQL Server database with Entity Framework. You’ll start from the absolute beginning: With “File->New Project” in Visual Studio.

By the end of the course you have created this application to organize friends and meetings. Everything you create in this application is stored in SQL Server with Entity Framework:

If you want to jump into XAML and frameworks like WPF and UWP to build enterprise applications, I recommend you to watch this course about building an Enterprise App with WPF, MVVM, and Entity Framework Code First.

After this course, you can learn how to test your ViewModels with unit tests by watching
WPF and MVVM: Test Driven Development of ViewModels.

With your solid knowledge, the next thing you can learn is how to create powerful model wrappers that track all the changes made to a model. Just watch this course: WPF and MVVM: Advanced Model Treatment. You’ll learn in this course how to track model changes, so that you can display changed fields in the UI with a different color. You even learn how to display the original value of a changed field in the tooltip. Beside all of this, you learn a lot about XAML, Data Binding, Attached Properties and Styles in this course.

Share this post

Comments (12)

  • Daniel Frahn Reply

    Very nice course with ultra-precisely explained source code!
    Maybe a bit too much, especially for experienced developers, as they already expect the code you are going to write.

    I was wondering why you always await Tasks, even if it’s the last instruction within a method.
    I think, simply returning the task (and removing the async keyword) is the way you go, otherwise you have different exception behavior, and a larger compiler generated code when using async/await.

    The only reason I can think of to await a method is when you want to wait for that result in order to execute further code.

    September 11, 2017 at 4:07 pm
    • Thomas Claudius Huber Reply

      Hi Daniel,

      thanks for the feedback. I tried to make this course also valuable for beginners, so yes, I can understand that advanced developers might find the explanations too detailed at some places.

      There are several reasons why I use the await keyword at the end of a method:
      – Disposables
      – Getting correct and expected exception behavior
      – …

      From my experience it’s the best to use the keywords everywhere and then optimize where needed. Take a look at this great article by Stephen Cleary:

      September 11, 2017 at 8:01 pm
  • Lais Gomes Reply

    Hi Thomas =)
    Your course is very cleanly, good for understand the world wpf.
    So, I’m developing app and with base in FriendOrganizer using TDD but i don’t know how test ShouldEnableSaveButtonIfChanges because, ever return false.

    public void ShouldEnableSaveButtonIfChanges()

    sutViewModel.InnerCatraca.Nome = “Digicon”;


    I use ViewModel.HasChanges method
    In App, run perfectly the button enable and disable correctly.
    Can you help this?

    Thanks, congratulation.

    October 25, 2017 at 9:54 pm
    • Thomas Claudius Huber Reply

      Hi Lais,

      thanks for the feedback.

      To your test method:
      Is your Load method async? If yes, you need to await it and make the test method async and returning a Task. Like here:

      public async Task ShouldEnableSaveButtonIfChanges()
      await sutViewModel.Load(_friendId);


      Without seeing the rest of your code I can’t say anything more to this. If you’re using the EF-DataContext to track changes, you might have to mock that behavior in your test too. The simplest way is to debug the code and take a look at the location where the HasChanges property of the ViewModel is set.

      October 26, 2017 at 2:16 pm
  • mohsen Reply

    Hi Thomas, what is another way to force validation in new item instead of using Friend.FirstName=””/Meeting.Title=””?

    November 28, 2017 at 8:01 pm
    • Thomas Claudius Huber Reply

      Hi Mohsen,

      you can walk the properties with Reflection and raise the validation for all of them. On the Pluralsight course page, you find a discussion tab. When you scroll through the answers you’ll find a way there.

      December 8, 2017 at 8:50 pm
  • Prateek Reply

    Hi Thomas,
    The whole course has been very nicely explained by you.
    However, after the module ‘Communicating between the view models’, even after following your instructions, the FriendDetailView is not displaying details of the Selected Friend.
    I am stuck here.
    Could you please guide as to where I am going wrong ?

    Thank you,

    September 4, 2018 at 12:27 pm
    • Thomas Claudius Huber Reply

      Hi Prateek,

      please ask these questions directly on the course homepage and I’ll answer them there, so others can also read the answer


      January 21, 2019 at 5:17 pm
  • Kyungmin Reply

    Hi Thomas,

    I have a question.

    In your course and code, before clearing friend wrapper collection(if it is not LookUpItem) you remove event handler in property
    But I don’t know why you remove event handler.

    Because you added new entities in collection, so no side effect exists even though we don’t remove event handler.

    Is it related with GC??

    January 4, 2019 at 3:32 am
    • Thomas Claudius Huber Reply

      Hi Kyungmin,

      please ask these questions directly on the course homepage and I’ll answer them there, so others can also read the answer


      January 21, 2019 at 5:20 pm
  • shahriyar Reply

    Thank you for preparing this course
    can you update this course by .net core 3 ?
    is there any difference to make this solution in .net core 3 ?
    is there dependency injection built in .net core that is better than autofac ?

    can you create a course for learning new version of prism with wpf ?

    tank you

    October 3, 2019 at 5:02 pm
    • Thomas Claudius Huber Reply

      There is not really something different in .NET Core 3. Dependency Injection is not better than Autofac. :)

      January 7, 2020 at 12:04 am

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.