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

EF6.x Correlating Poor Performing SQL to Application Code

When using an O/RM, poor performing SQL statements are often not discovered until you (or your DBA) find that a particular query is slowing down your database server. At this point, it becomes hard to identify which piece of application code is causing that SQL to be executed.   An interceptor to log slow/failed SQL … Continue reading EF6.x Correlating Poor Performing SQL to Application Code

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

Customizing ‘Reverse Engineer Code First’ in the EF Power Tools

Beta 2 of the Entity Framework Power Tools was recently released. By far the most popular feature out of these power tools is the ability to reverse engineer a Code First model from an existing database. Admittedly ‘Code First’ wasn’t the best choice of names… Code First is really just a code-based alternate to the … Continue reading Customizing ‘Reverse Engineer Code First’ in the EF Power Tools