EF Core 1.1: Run Reverse Engineer from Code

EF Core includes the ability to reverse engineer a model from an existing database - using the Scaffold-DbContext command in Visual Studio, or the dotnet ef dbcontext scaffold command for .NET CLI. For an introduction, see Getting Started with an Existing Database. The Problem The commands mentioned above are designed to be invoked on a … Continue reading EF Core 1.1: Run Reverse Engineer from Code

Processor named ‘T4VSHost’ could not be found for the directive named ‘CleanupBehavior’

There are two scenarios in which you may see the 'Processor named ‘T4VSHost’ could not be found for the directive named ‘CleanupBehavior’' error after installing Visual Studio 2012 Update 1. Inside Visual Studio when code is being generated from an EF model - this isn't supposed to happen and something probably went wrong during install. … Continue reading Processor named ‘T4VSHost’ could not be found for the directive named ‘CleanupBehavior’

EF6: Writing Your Own Code First Migration Operations

Migrations provides a set of strongly typed APIs for performing common operation, for example CreateIndex("dbo.Blogs", "Url"). We also provide a method that allows you to run arbitrary SQL when you want to do something that isn’t supported by the API, for example Sql("GRANT SELECT ON dbo.Blogs to guest"). There are some disadvantages to the Sql … Continue reading EF6: Writing Your Own Code First Migration Operations

Extending And Customizing Code First Models – Part 2 of 2

Here is the scenario, your company ships a library or application that contains a Code First model for accessing the database. Your customers want to extend this model to include extra types/properties to meet their specific business needs. These types/properties will be stored in additional tables/columns in the application database. In Part 1 we looked at … Continue reading Extending And Customizing Code First Models – Part 2 of 2

Extending and Customizing Code First Models – Part 1 of 2

Here is the scenario, your company ships a library or application that contains a Code First model for accessing the database. Your customers want to extend this model to include extra types/properties to meet their specific business needs. These types/properties will be stored in additional tables/columns in the application database. In this post I’ll walk … Continue reading Extending and Customizing Code First Models – Part 1 of 2

EF6 Code First: Mapping All Private Properties Using Custom Conventions

A while back I blogged about mapping to private properties with Code First. The approach shown in that post works with EF4.1 onwards but it requires you to explicitly configure every private property that you want included in your model. That’s going to get tiresome if you have a big model and want all private … Continue reading EF6 Code First: Mapping All Private Properties Using Custom Conventions