elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
5.88k stars 1.06k forks source link

[BUG] Wrong RuntimeDBContext in 3.1.2 for Oracle #5230

Closed b0rv3g4r4 closed 2 weeks ago

b0rv3g4r4 commented 4 weeks ago

Description

In the SetupOracle of RuntimeDbContext, the SerializedKeyValuePair is bad defined

Steps to Reproduce

To help us identify the issue more quickly, please follow these guidelines:

  1. Detailed Steps: We are upgrading to 3.1.2 using a Oracle provider for Elsa and when we generate the migrations for Oracle we found in the Runtime module a problem with SerializedKeyValuePair

  2. Code Snippets: modelBuilder.Entity<SerializedKeyValuePair>().Property("Value").HasColumnType("NCLOB");

  3. Attachments:

  4. Reproduction Rate:

  5. Video/Screenshots:

  6. Additional Configuration:

Expected Behavior

The context defines a property "SerializedValue" for SerializedKeyValuePair

Actual Behavior

The context defines a property "Value" for SerializedKeyValuePair

Screenshots

Environment

Log Output

System.InvalidOperationException: The property 'Value' cannot be added to the type 'SerializedKeyValuePair' because no property type was specified and there is no corresponding CLR property or field. To add a shadow state property, the property type must be specified.
   at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.Property(Type propertyType, String propertyName, MemberInfo memberInfo, Nullable`1 typeConfigurationSource, Nullable`1 configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.Property(String propertyName, Nullable`1 configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder.Property(String propertyName)
   at Elsa.EntityFrameworkCore.Modules.Runtime.RuntimeElsaDbContext.SetupForOracle(ModelBuilder modelBuilder)
   at Elsa.EntityFrameworkCore.Common.ElsaDbContextBase.OnModelCreating(ModelBuilder modelBuilder)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, ModelDependencies modelDependencies)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()`
glime-ai[bot] commented 4 weeks ago

Based on the context provided, it seems like there is a mismatch between the property name expected in the SerializedKeyValuePair entity and the one being used in the SetupOracle method of the RuntimeDbContext. The error message indicates that the property 'Value' does not exist on the 'SerializedKeyValuePair' type, and you are expecting a property named 'SerializedValue'.

To resolve this issue, you should ensure that the property name used in the SetupOracle method matches the actual property name defined in the SerializedKeyValuePair entity. If the correct property name is 'SerializedValue', then the code snippet should be updated to reflect that:

modelBuilder.Entity<SerializedKeyValuePair>().Property("SerializedValue").HasColumnType("NCLOB");

This change should be made in the RuntimeElsaDbContext.SetupForOracle method where the entity type is being configured for Oracle.

If you have access to the source code of the SerializedKeyValuePair entity, you should verify the correct property name. If 'SerializedValue' is indeed the correct property, then the above change should fix the issue. If the property name is different, you should use the actual property name in the SetupOracle method.

Please make sure to apply this change and regenerate the migrations for Oracle to see if the issue is resolved.

This comment was generated by Glime.

sfmskywalker commented 2 weeks ago

Merged