One does not simply insert explicit IDs in Entity Framework Core

How to resolve “Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF”

Okay, okay – another super simple thing that I messed up, fixed, and decided to document :) This time I messed up a simple operation in Entity Framework Core operation on a simple entity, and hopefully I’ll save someone else some trouble! Onwards to the issue, then! Problem So when you’re trying to insert stuff into your database – somewhat like shown in the example below: var entity = new MyEntity(){ Id = 1337, Name = "My Entity" }; _ctx.MyEntities.Add(entity); _ctx.SaveChanges(); You get an error…Continue reading How to resolve “Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF”

Entity Framework Core logo

How to resolve persistent “Build started… Build failed.” when trying to run Entity Framework Core commands?

This time, I’m happy to present you perhaps the simplest way of fixing an annoying and persistent issue with a misleading error message! Wait, does that sound familiar? It’s almost like that’s what half of my articles are about… Anyway, I was happily going my way about creating a couple of new fields to an entity and then scaffolding my changes to a new migration using Entity Framework Core’s Add-Migration, but this happened: Build started… Build failed. “Oh”, I thought. “I must have messed something…Continue reading How to resolve persistent “Build started… Build failed.” when trying to run Entity Framework Core commands?

SharePoint Home Sites – a Game Changer?

This topic seems to be on everyone’s mind right now: SharePoint Home Sites. They’re finally rolling out (again). Or maybe even rolled out, in case this article ends up late in my publishing queue! But what are they? How do you create SharePoint Home sites? How do you best use them in your organization? To take a step back, let’s first take a step upwards – to get the 1000-feet view! Getting the big picture – why is Microsoft doing this stuff in the first…Continue reading SharePoint Home Sites – a Game Changer?

WHAT IN TARNATION EF CORE?

How to resolve another “An error occurred while updating the entries” exception in Entity Framework Core

This article offers yet another possible fix to an issue, where trying to call SaveChanges() in Entity Framework Core throws a pretty generic “An error occurred while updating the entries”-exception, and you’re left wondering what in tarnation is wrong this time. And admittedly, that’s a really generic error, so it could be pretty much whatever. But in this article, I’ll go through one possibility. Problem So I was just pushing in some new rows to an incredibly simple table in my small Azure MS SQL…Continue reading How to resolve another “An error occurred while updating the entries” exception in Entity Framework Core