Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

EF Core bug requires sharing codebase with EF team #8142


User avatar
0
tusksoft created

We've run into a bug with EF Core which appears to be in the EF Core team's court, not ASP.NET Zero's. The bug is documented here: https://github.com/aspnet/EntityFrameworkCore/issues/18178 It was supposed to be fixed with the 3.1.0 release which came out today, but we continue to experience the issue after upgrading Nuget packages. So far the only project we're experiencing this with is our ASP.NET Zero based solution at v8.0.0, and as such we need to share the codebase with the EF team.

How can we go about sharing the A0 codebase with the EF Core team without violating your license terms?


8 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi tusksoft

    Since it is a problem with EF Core, I believe you can directly use EF Core's application to reproduce it without sharing zero code.

  • User Avatar
    0
    tusksoft created

    I have been unable to reproduce in a templated app. I can, however, reproduce in a pristine copy of A0 8.0.0. Could you or I provide a copy to their team behind auth challenge and share credentials privately? A demo app would be sufficient.

    This bug is having a pretty severe affect on our workflow for an application we've just started working on so we really need to get this addressed. I'm not sure how to work around it in A0, and A0 is the only app we have that's exhibiting this behavior. If you all can find a workaround, we're fine with that as well. We just need it fixed for 8.0.0 to be a viable platform for us to move forward with.

  • User Avatar
    0
    maliming created
    Support Team

    Can you reproduce the problem using Zero's Demo project? If you can share the steps, I will try to reproduce it using a plain ef core application.

  • User Avatar
    0
    tusksoft created

    Yes, it can be reproduced in the demo project. In a pristine solution just run add-migration followed by remove-migration . You can actually skip adding the empty migration and just run remove-migration to achieve the same exception.

    We've had to nuke ALL of the migrations that come with A0 and recreate them as a single migration in order to get things working properly. We're avoiding committing this change as it will create additional pain when upgrading the A0 framework.

    In the github issue I linked to the problem was reported fixed, but the use case here does not seem to be covered by the fix. I would venture to guess that if the SQL Server column types were explicitly defined in the cs.designer files all would work as expected, but that requires a prohibitive time investment on our end and presents the same problem in terms of upgradability. This is something your team would need to do to maintain maximum upgradability of the framework.

    One final note, I've tried to recreate this problem in a VS2019 templated project with no success. These were the steps I used:

    1. Create project
    2. nuke templated migrations
    3. roll back EF related packages to 2.x versions and update context code as necessary to be able to run add-migration successfully (see https://stackoverflow.com/questions/45782446/unable-to-create-migrations-after-upgrading-to-asp-net-core-2-0)
    4. add an initial migration
    5. update EF packages to 3.1.x
    6. run add-migration
    7. run remove-migration
  • User Avatar
    0
    maliming created
    Support Team

    Thank you for the information, we will consider rebuilding all migrations or other solutions.

    https://github.com/aspnetzero/aspnet-zero-core/pull/2817

  • User Avatar
    0
    tusksoft created

    While our original issue has been fixed in the upgrade to 8.1, we now have another bug when adding new migrations. Here are the steps to reproduce this issue on a clean demo project of v.8.1:

    1. Create project
    2. Create new domain class
    3. Add new migration

    The migration adds the following column:

                migrationBuilder.AddColumn<int>(
                    name: "EditionPaymentType",
                    table: "AppSubscriptionPayments",
                    nullable: false,
                    defaultValue: 0);
    

    Because of this column, running update-database produces the following exception:

    Column names in each table must be unique. Column name 'EditionPaymentType' in table 'AppSubscriptionPayments' is specified more than once.
    

    Here is the Stack Trace for the exception:

    Applying migration '20200102200758_Add_User_With_Address'.
    Failed executing DbCommand (7ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
    ALTER TABLE [AppSubscriptionPayments] ADD [EditionPaymentType] int NOT NULL DEFAULT 0;
    Microsoft.Data.SqlClient.SqlException (0x80131904): Column names in each table must be unique. Column name 'EditionPaymentType' in table 'AppSubscriptionPayments' is specified more than once.
       at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite)
       at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
       at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
       at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
       at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
       at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
       at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0()
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
    ClientConnectionId:359e964b-b07a-4130-856e-db417d8e28ec
    Error Number:2705,State:4,Class:16
    
  • User Avatar
    0
    maliming created
    Support Team

    hi @tusksoft please see https://github.com/aspnetzero/aspnet-zero-core/pull/2864

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.