Q: Entity Framework Core - Custom Migration stopped working For a while now I've had a custom migration in my Entity Framework Core project that creates some SQL objects - stored procedures and functions.
It looks something like this:
using Microsoft.EntityFrameworkCore.Migrations;

namespace CaseFlow_API.Migrations
{
    public partial class AdditionalSQLObjects : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // Functions
            var f_exampleFunction = @"CREATE OR REPLACE FUNCTION public.f_exampleFunction(
    character varying,
    character varying,
    character varying,
    integer)
/*
SOME SQL CODE
*/
";

            migrationBuilder.Sql(f_exampleFunction);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
        }
    }
}

However now it stopped working - functions and procedures are not created when updating the db. I don't think I changed anything in how migrations are created. What I would do usually is that I'd run
dotnet ef migrations add Initial
dotnet ef database update

I tried dropping all migrations, dropping the database, recreating the AdditionalSQLObjects.cs class. I have no idea how to debug/fix this.
Can you please point me to places where I can fix this?

A: Ok, so the custom migration finally works. Here's what I did (added class attributes):
[DbContext(typeof(CaseflowingContext))]
[Migration("CustomMigration_AdditionalSQLObjects")]
public partial class AdditionalSQLObjects : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
        {
          //miration code
        }
}

I have no idea what happened, because this migration used to work without the attributes, but I'll take it.
