Another day, another issue. This time, I was absent-mindedly following the guidance for a project on how to generate .sql files for .NET EF Core code-first migrations. Don’t ask why that was required, but it was. My migration was simple. Adding an entity with just a few properties. And Entity…Continue reading “dotnet ef script” or “Script-Migration” producing empty .sql files?
This post describes the easiest way to debug the issues that may stop your Seed-method in Configuration.cs from going through. This problem concerns typically your ASP.NET MVC projects, either on .NET Framework or .NET Core – the same basic idea should work for both situations. The solution here shows you,…Continue reading The easiest way to debug Seed-method in Code-first migrations in Entity Framework
This post describes how to run Entity Framework’s code-first migrations against a database located in Windows Azure. This is done by running the Update-Database commandlet with suitable switches, see below. The problem and symptoms Okay, so you’re developing your MVC+EF cool web app with a database in Azure, and you’re…Continue reading Applying Entity Framework’s Code-First Migrations against a Database in Azure by running Update-Database
While using Entity Framework and code-first migrations, Entity Framework (EF) creates the indexes for you – but what if you need to create a custom one, explicitly based on a certain field/column? Then you’ll have to tell EF which one to use as a key column. Usually, it’s easy –…Continue reading Fixing the error: “Column XX in table dbo.YY is of a type that is invalid for use as a key column in an index.”
This post describes an issue with EF’s code-first migrations, when mapping between DB’s DateTime (datetime2) and C#’s DateTime simply fails, and results in the Update-Database cmdlet failing, too. It is more or less a prime example of a situation, where the error itself tells very little about the actual issue,…Continue reading Fixing “An error occurred while updating the entries” while running code-first migrations in MVC 5 app