Moving Forward – Entity Framework Code First

Recently, with the release of the release of the CoE.EntityFramework extension for auditing, there has been a great deal of discussion, introspection, and research regarding the use of Code First vs. Code First From existing Database workflows when using the Entity Framework.

Obviously, in many cases, using the Code First workflow may not appear at first to be possible given that many applications, old and new, begin with an existing database or building a new database prior to the start of any serious coding.

I am suggesting that this way of thought is flawed and that the Code First workflow is possible in almost any situation. Indulge me while I explain.

Fact: As developers, we are generally responsible for the construction of the database schema and performance tuning, thus at the very least, when a database is provisioned by the DBA group, it is almost without fail devoid of any schema, structure, or data (i.e. empty) and we are granted ‘dbo‘ access to the database. We are “gods”!!!

Moving to Code First from Database First for an Existing Solution

If you are on a project or maintaining a solution that involves an existing database and the database structure is sound (not always a given), you may use the Code First From Existing Database workflow to add the Entity Framework to your solution and immediately enable migrations. There are several T4 Templates available other than the default to generate the entities and datacontext in an existing solution in order to suit your needs.

From this point on, you can take advantage of using the Code First workflow for changes to the database.

Moving to Code First with a Poorly Designed Database

If you are maintaining a solution that has a poorly designed database as the backing store, rather than use the aforementioned migration to a Code First workflow, it may be better to simply start over. The cases that would qualify under this scenario are those applications that have backing stores that resemble a spreadsheet more than they do a database.

Starting with a Code First Workflow

This workflow is best workflow! If you have the opportunity to begin with a Code First workflow for the backing store design, take it. The advantages far outweigh the learning curve required to start working with the Entity Framework.

The Way Ahead

Moving forward within the City of Edmonton, the use of the Code First workflow will be encouraged in order to provide standard, maintainable, and extensible solutions for out clients.


Over the course the new few weeks and months, I will be posting tips, tricks, and guidance on implementing some of the common (and not so common) methods for using the Entity Framework.

Interesting Read on Managing Teams

Probably the most important component of any organization is the concept of “teams”.

In my opinion, a team is so much more that a random group of individuals thrown together to accomplish some task, but more a collection of individuals that have developed mutual respect for each other’s abilities and are also keenly aware of each other’s weaknesses.

A “group” will eventually get things done (or not!), while a “team” is capable of producing deliverables that are of a higher quality and greater than each individual is capable of.

If you have even been on a team, I expect that the feelings one may experience in going back into a group may include a sense of loss, some resentment at losing the team experience, and a need to belong to a team again. I for one have been extremely fortunate to have been on many teams during my career that has resulted in higher job satisfaction and sense of self esteem than simply being a member of some of the many groups. Teams are much more rewarding.

A corporation, whether public or private, gains many tangible and non-tangible benefits by encouraging the creation and support of teams.

The building and support of teams within an organization begins with a corporate culture that simply not only offers platitudes about the importance of teams, but actively manages their resource to let teams develop and thrive.

I found an interesting article titled Demoralize Your Teams Quickly And Efficiently With Micromanagement. It is unfortunate and extremely saddening that this management style is so persuasive in many organizations.


Announcing the CoE.EntityFramework NuGet Package

One of the goals that I have set for myself, one that may not be quite in line with the views of other individuals, is to create re-usable assets that may be used by other developers and teams to implement specific behaviours in the products and services that we deliver to our customers, not our leadership.

This view regarding the fact that we ultimately serve our customers and not Information Technology (IT) leadership has for the most part, served me well with few real consequences that I am aware of (I may be a bit ignorant of the current state, but .. meh … I am also wonderfully apathetic!).

Today, I am announcing the CoE.EntityFramework NuGet package available on the CoE NuGet Server. If you have the CoE NuGet Server registered in your Visual Studio IDE, the CoE.EntityFramework NuGet package will automatically appear as one of the available packages that may be installed.

The CoE.EntityFramework NuGet package extends the standard EntityFramework 6 DbContext class to provide varying degrees of auditing behaviours.

The documentation for the CoE.EntityFramework is available here. There are may examples and How To articles available to get you up to speed on using the CoE.EntityFramework package to add standardized logging to almost any application.

Happy and Productive Coding!