efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Unexpected PendingModelChangesWarning on initial creation of database via migrations

Open peteraritchie opened this issue 2 years ago • 37 comments

When the entity config doesn't include OwnsMany the error does not occur. his can be toggled with INCLUDE_ACCOUNT_HOLDERS: remove INCLUDE_ACCOUNT_HOLDERS as a compile-time constant from Domain and Infrastructure and the error does not occur.

I could not reproduce when everything was in a single project.

Steps to reproduce:

  1. git clone -b main --depth 1 https://github.com/peteraritchie/EfPendingModelChangesWarning.git
  2. cd EfPendingModelChangesWarning/src
  3. dotnet ef migrations add InitialCreate --startup-project Api --project Infrastructure
  4. dotnet ef database update --startup-project Api --project Infrastructure

Include your code

See steps and https://github.com/peteraritchie/EfPendingModelChangesWarning

Include stack traces

Output from dotnet ef database update:

System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AccountSqliteDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
   at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition`1.Log[TLoggerCategory](IDiagnosticsLogger`1 logger, TParam arg)
   at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.PendingModelChangesWarning(IDiagnosticsLogger`1 diagnostics, Type contextType)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AccountSqliteDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.

Include verbose output

Verbose output from dotnet ef --verbose migrations add InitialCreate --startup-project Api --project Infrastructure

Using project 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj'.
Using startup project 'C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj'.
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\peter\AppData\Local\Temp\tmpbpsjyc.tmp /verbosity:quiet /nologo C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\peter\AppData\Local\Temp\tmpsuql5r.tmp /verbosity:quiet /nologo C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj
Build started...
dotnet build C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj /verbosity:quiet /nologo /p:PublishAot=false
C:\Users\peter\src\experiment\DDDReference\src\Domain\PostalAddress.cs(5,16): warning CS8618: Non-nullable property 'Street' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. [C:\Users\peter\src\experiment\DDDReference\src\Domain\Pri.DDDReference.Domain.csproj]

Build succeeded.

C:\Users\peter\src\experiment\DDDReference\src\Domain\PostalAddress.cs(5,16): warning CS8618: Non-nullable property 'Street' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. [C:\Users\peter\src\experiment\DDDReference\src\Domain\Pri.DDDReference.Domain.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:06.83

Build succeeded.
dotnet exec --depsfile C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.deps.json --additionalprobingpath C:\Users\peter\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.runtimeconfig.json C:\Users\peter\.dotnet\tools\.store\dotnet-ef\9.0.0\dotnet-ef\9.0.0\tools\net8.0\any\tools\netcoreapp2.0\any\ef.dll migrations add InitialCreate --assembly C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Infrastructure.dll --project C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj --startup-assembly C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.dll --startup-project C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj --project-dir C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\ --root-namespace Pri.DDDReference.Infrastructure --language C# --framework net8.0 --nullable --working-dir C:\Users\peter\src\experiment\DDDReference\src --verbose
Using assembly 'Pri.DDDReference.Infrastructure'.
Using startup assembly 'Pri.DDDReference.Api'.
Using application base 'C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0'.
Using working directory 'C:\Users\peter\src\experiment\DDDReference\src\Api'.
Using root namespace 'Pri.DDDReference.Infrastructure'.
Using project directory 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding DbContext classes in the project...
Found DbContext 'AccountSqliteDbContext'.
Finding application service provider in assembly 'Pri.DDDReference.Api'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Using context 'AccountSqliteDbContext'.
Finding design-time services referenced by assembly 'Pri.DDDReference.Api'...
Finding design-time services referenced by assembly 'Pri.DDDReference.Infrastructure'...
No referenced design-time services were found.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.Sqlite'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.Sqlite'.
Finding IDesignTimeServices implementations in assembly 'Pri.DDDReference.Api'...
No design-time services were found.
Writing migration to 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Migrations\20241114183900_InitialCreate.cs'.
Writing model snapshot to 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Migrations\AccountSqliteDbContextModelSnapshot.cs'.
Done. To undo this action, use 'ef migrations remove'

verbose output from dotnet ef --verbose database update --startup-project Api --project Infrastructure

Using project 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj'.
Using startup project 'C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj'.
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\peter\AppData\Local\Temp\tmpshmzoi.tmp /verbosity:quiet /nologo C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\peter\AppData\Local\Temp\tmprm3hs3.tmp /verbosity:quiet /nologo C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj
Build started...
dotnet build C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj /verbosity:quiet /nologo /p:PublishAot=false

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.15

Build succeeded.
dotnet exec --depsfile C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.deps.json --additionalprobingpath C:\Users\peter\.nuget\packages --additionalprobingpath "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.runtimeconfig.json C:\Users\peter\.dotnet\tools\.store\dotnet-ef\9.0.0\dotnet-ef\9.0.0\tools\net8.0\any\tools\netcoreapp2.0\any\ef.dll database update --assembly C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Infrastructure.dll --project C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\Pri.DDDReference.Infrastructure.csproj --startup-assembly C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0\Pri.DDDReference.Api.dll --startup-project C:\Users\peter\src\experiment\DDDReference\src\Api\Pri.DDDReference.Api.csproj --project-dir C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\ --root-namespace Pri.DDDReference.Infrastructure --language C# --framework net8.0 --nullable --working-dir C:\Users\peter\src\experiment\DDDReference\src --verbose
Using assembly 'Pri.DDDReference.Infrastructure'.
Using startup assembly 'Pri.DDDReference.Api'.
Using application base 'C:\Users\peter\src\experiment\DDDReference\src\Api\bin\Debug\net8.0'.
Using working directory 'C:\Users\peter\src\experiment\DDDReference\src\Api'.
Using root namespace 'Pri.DDDReference.Infrastructure'.
Using project directory 'C:\Users\peter\src\experiment\DDDReference\src\Infrastructure\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding DbContext classes in the project...
Found DbContext 'AccountSqliteDbContext'.
Finding application service provider in assembly 'Pri.DDDReference.Api'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Using context 'AccountSqliteDbContext'.
Finding design-time services referenced by assembly 'Pri.DDDReference.Api'...
Finding design-time services referenced by assembly 'Pri.DDDReference.Infrastructure'...
No referenced design-time services were found.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.Sqlite'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.Sqlite'.
Finding IDesignTimeServices implementations in assembly 'Pri.DDDReference.Api'...
No design-time services were found.
System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AccountSqliteDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
   at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition`1.Log[TLoggerCategory](IDiagnosticsLogger`1 logger, TParam arg)
   at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.PendingModelChangesWarning(IDiagnosticsLogger`1 diagnostics, Type contextType)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AccountSqliteDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.

Include provider and version information

EF Core version: 9.0.0 (first reproduced with 8.0.10 Database provider: Microsoft.EntityFrameworkCore.Sqlite 9.0.0 Target framework: NET 8.0 Operating system: Windows IDE: Visual Studio 2022 17.12.0

peteraritchie avatar Nov 14 '24 18:11 peteraritchie

@peteraritchie Can you run dotnet ef migrations add Two --startup-project Api --project Infrastructure or similar immediately after adding the first migration? If the Up and Down methods in the second migration are not empty, can you post the contents here?

ajcvickers avatar Nov 14 '24 20:11 ajcvickers

@ajcvickers The Up and Down methods were not empty:

namespace Pri.DDDReference.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class Two : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_account_holder_account_account_id",
                table: "account_holder");

            migrationBuilder.AddForeignKey(
                name: "FK_account_holder_account_account_id",
                table: "account_holder",
                column: "account_id",
                principalTable: "account",
                principalColumn: "id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_account_holder_account_account_id",
                table: "account_holder");

            migrationBuilder.AddForeignKey(
                name: "FK_account_holder_account_account_id",
                table: "account_holder",
                column: "account_id",
                principalTable: "account",
                principalColumn: "id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}

peteraritchie avatar Nov 15 '24 13:11 peteraritchie

@ajcvickers Probably not a surprise to you, but a subsequent dotnet ef migrations add Three --startup-project Api --project Infrastructure resulted in the same Up and Down methods as Two.

peteraritchie avatar Nov 15 '24 13:11 peteraritchie

@peteraritchie Thanks for testing this--it confirms this is a bug in EF8/EF9. I will let @AndriySvyryd decide if he needs more info.

ajcvickers avatar Nov 15 '24 13:11 ajcvickers

@peteraritchie Thanks for testing this--it confirms this is a bug in EF8/EF9. I will let @AndriySvyryd decide if he needs more info.

Let me know if there's anything you need @AndriySvyryd

peteraritchie avatar Nov 15 '24 19:11 peteraritchie

System.InvalidOperationException: 'An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AppDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.'

and when i run add-migration updateToNet9 -c AppDbContext

using  Microsoft.EntityFrameworkCore.Migrations;

namespace App.Data.Migrations
{
    /// <inheritdoc />
    public partial class updateToNet9 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {

        }
    }
}

alraseensaad avatar Nov 15 '24 22:11 alraseensaad

@alraseensaad Can you create a small repro and open a new issue? You seem to be hitting a different issue

AndriySvyryd avatar Nov 15 '24 23:11 AndriySvyryd

System.InvalidOperationException: 'An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'AppDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.'

and when i run add-migration updateToNet9 -c AppDbContext

using  Microsoft.EntityFrameworkCore.Migrations;

namespace App.Data.Migrations
{
    /// <inheritdoc />
    public partial class updateToNet9 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {

        }
    }
}

I'm getting the same error, not sure how to resolve this;

command after Initial script was generated: dotnet ef database update --startup-project ../Ordering.API --context OrderingContext

..." Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'."

pastrasigns avatar Nov 16 '24 01:11 pastrasigns

@pastrasigns Do you still get it after adding a new migration?

AndriySvyryd avatar Nov 16 '24 02:11 AndriySvyryd

@pastrasigns Do you still get it after adding a new migration?

@AndriySvyryd Yes, even after adding the new migration

The exception still thrown in Migrate() method

baseDbContext.Database.EnsureDeleted();
baseDbContext.Database.Migrate();

I try to use dotnet ef update command and it works fine and all migrations applied to the database after that I tried to use baseDbContext.Database.Migrate(); without using EnsureDeleted() and it's still thrown the exceptions.

To debug further, I checked the status of migrations using:

baseDbContext.Database.GetPendingMigrations();
baseDbContext.Database.GetAppliedMigrations();
baseDbContext.Database.Migrate();

so the GetPendingMigrations() method returned empty and GetAppliedMigrations() count 49 which is the list of migrations which supposed to work fine but it throws in baseDbContext.Database.Migrate();

Finally, as a workaround, I configured warnings to suppress the PendingModelChangesWarning exception:

options.ConfigureWarnings(warnings => { warnings.Log(Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.PendingModelChangesWarning); });

And that's worked

alraseensaad avatar Nov 16 '24 16:11 alraseensaad

Same here, whenever I try to run the initial migration to create the database, I get this error:

> dotnet ef migrations add InitialCreate

Build started...
Build succeeded.
Done. To undo this action, use 'ef migrations remove'
> dotnet ef database update
Build started...
Build succeeded.
System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'ApplicationDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
   at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition`1.Log[TLoggerCategory](IDiagnosticsLogger`1 logger, TParam arg)
   at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.PendingModelChangesWarning(IDiagnosticsLogger`1 diagnostics, Type contextType)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'ApplicationDbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
`

blfuentes avatar Nov 17 '24 19:11 blfuentes

I have same problem, i upgrade to .net 9 and when start Program.cs to execute migrate, a have same error

gustavomcastro avatar Nov 17 '24 20:11 gustavomcastro

I’m having the same issue. After upgrading my project from .NET 8 to .NET 9, I ran into this migration problem. Everything worked fine in .NET 8, but as soon as I moved the codebase to a new repository and upgraded it to .NET 9, the issue popped up. I’ve already tried deleting the old migration files and creating new ones, but the error keeps showing up.

appDbContext.Database.Migrate();

System.InvalidOperationException: 'An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'dbContext' has pending changes. Add a 
new migration before updating the database. This exception can be suppressed or logged by passing event ID 
'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.'

nbiyanka avatar Nov 18 '24 05:11 nbiyanka

I have the same issue

kiwiinlondon avatar Nov 18 '24 18:11 kiwiinlondon

@pastrasigns @alraseensaad @blfuentes @nbiyanka Create a small repro and open a new issue


@gustavomcastro @kiwiinlondon

Create a new migration.

  1. If the error does not show up anymore then it's by design.
  2. If you still get an error and the new migration is empty like https://github.com/dotnet/efcore/issues/35110#issuecomment-2480249117 then create a small repro and open a new issue
  3. If you still get an error and the new migration looks like https://github.com/dotnet/efcore/issues/35110#issuecomment-2478875583 then just use the 👍 reaction on the first comment, no need to add additional comments

AndriySvyryd avatar Nov 18 '24 21:11 AndriySvyryd

@AndriySvyryd i created new migration whem i start de API and use context.Migrate(), i have the error.

I did downgrade to version 7 until resolve this issue

gustavomcastro avatar Nov 18 '24 23:11 gustavomcastro

I'm running into this issue (I get an empty migration), oddly when I execute dotnet ef migrations has-pending-model-changes it says

No changes have been made to the model since the last migration.

hahn-kev avatar Nov 19 '24 08:11 hahn-kev

Wow, Not sure why this basic bugs got leaked into stable released version?

baoduy avatar Nov 20 '24 03:11 baoduy

My team and I were testing out this example branch, we updated the postgres to use external sql server database (not containers - localhost)

We updated this work around for this BUG:

        //services.AddDbContext<OrderingContext>(options =>
        //{
        //    options.UseNpgsql(builder.Configuration.GetConnectionString("orderingdb"));
        //});
        //builder.EnrichNpgsqlDbContext<OrderingContext>();

        builder.AddSqlServerDbContext<OrderingContext>(
            "orderingdb", configureDbContextOptions: dbContextOptionsBuilder =>
            {
                dbContextOptionsBuilder.UseSqlServer();
                dbContextOptionsBuilder.ConfigureWarnings(
                    warnings => warnings.Ignore(RelationalEventId.PendingModelChangesWarning));
            });

pastrasigns avatar Nov 20 '24 14:11 pastrasigns

~This happens in our linux CI but not locally on mac.~

Got it to happen locally too

cliedeman avatar Nov 20 '24 18:11 cliedeman