EF Core has a well defined set of concepts that can be configured for entity types and properties. Examples include the primary key of an entity, whether a property is required or optional, etc. Aside from these "baked in" concepts, there are metadata annotations that allow additional concepts to be added to the model. For example, the … Continue reading EF Core 1.1: Read Only Entities & Extending Metadata with Annotations
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
EF Core - Learn how to extend the reverse engineer services to perform pluralization and singularization when reverse engineering a model from an existing database.
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
One of the most popular posts on my blog has been EF6.1 Mapping Between Types & Tables. Someone asked me this week about getting the property/column mapping in addition to the type/table mapping. There isn’t a whole lot to say (other than the code is horrible and this will look a whole lot better in … Continue reading EF6.1 Get Mapping Between Properties and Columns
A semi-common issue that folks hit with Entity Framework is that the in-memory semantics for “relationship fixup” are different than how SQL Server performs joins with regard to trailing spaces in strings. Relationship fixup is the process where EF looks at primary and foreign key values and populates navigation properties when they match. The … Continue reading EF6.1–Workaround Trailing Blanks Issue in String Joins
Today I had a question show up in my inbox about finding the key properties of a given entity type. Searching around I didn’t find a good existing post about this, so here is the code you need. The code provides a couple of simple extension methods to DbContext. Note that the code is somewhat … Continue reading EF6.1 Getting Key Properties for an Entity