Entity Framework Code First Seeding with Related Data

A quick tip I stumbled upon while working on an MVC application using Entity Framework Code First. In order to Seed Related Data when using Entity Framework Code First, it’s important to give items temporary ID’s before calling the seed method. Otherwise, when the database is seeded you will end up with Conflicted Inserts

By |2017-07-24T08:33:17+01:00July 27th, 2013|.Net Framework, Data, Entity Framework, Tips|0 Comments

Adding EF POCO Classes to TFS Source Control

I have various projects which included Entity Framework POCO (Plain Old CLR Object) Classes. By default, these are not automatically included in TFS Source Control. To add these classes in VS2012; Open the Team Explorer Window using View>Team Explorer You will see a list of shortcuts... My Work, Pending Changes and so on; Under "Pending [...]

Adding EF5 POCO’s to TFS Source Control

While attempting to build my TFS based solution, the build failed reporting that it couldn’t find my EF5 POCO Classes. After some digging around it seems that these files aren’t automatically included under TFS Source Control. In order to enable this (For VS 21012), we must perform the following actions; 1. Open the Team Explorer [...]

Enabling MVVM INotifiyPropertyChanged in EF 5 POCO Entities created using the EF 5.x DbContext Generator

While combining EF5 with WPF MVVM, I noticed that changes to individual properties within my bound DataContext weren’t updating the UI. This was of course because the the actual DataContext itself isn’t changing, but only the POCO Properties housed within in. However, each of the POCO Properties don’t individually raise an INotifyPropertyChanged event. In order [...]

By |2012-12-05T00:28:00+00:00December 5th, 2012|.Net Framework, Entity Framework, MVVM, VB.net, WPF|0 Comments

Using Reflection to retrieve Entity Framework Data using a Column Name String

If you ever need to retrieve data from EF using the name of a column, rather than the built in Intellisense, then the following vb.net code snippet may help. GetType(TypeOfEntity).GetProperty(NameOfColumn).GetValue(ActualEntity, Nothing)TypeOfEntity is the name of the Entity from which you wish to retrieve data. NameOfColumn is obviously the Name of the Column from which you [...]

By |2017-07-24T08:33:19+01:00November 20th, 2012|.Net Framework, C#, Data, Entity Framework, VB.net, Visual Studio|0 Comments