- ABP Framework version: v7.4.0
- UI Type: Blazor Server
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace:
- Steps to reproduce the issue:
Quick background. My app relates to the exchange of foreign currencies. I have two entities... a "Currency" (eg. UD dollar, Japanese Yen, etc.) and a "CurrencyPair" (eg. USD/JPY, EUR/USD, etc.). So I have a "Currency" entity with a GUID ID and a name (eg. "USD", "EUR", "JPY", etc.), and I have a "CurrencyPair" entity with a GUID ID and a name (e. "EUR/USD", "USD/JPY", etc.). I created both entities. At this point, there is no relationship between them, and each entity only has an ID and a Name. I was able to "Save and Generate" these entities, which built the code. And I ran the app with no issues.
Now I am trying to define the navigation properties. A "CurrencyPair" must reference two "Currency" entities. For the currency pair called "USD/JPY", "USD" is called the "quote" currency and "JPY" is referred to as the "base" currency. So I have two navigation properties I need called "QuoteCurrency" and "BaseCurrency". So, I defined these as follows when defining the navigation properties on the "CurrencyPair" entity:
- On the "Basic" tab I selected "Currencies.cs" for the Entity.
- For Display Property I selected "Name".
- I toggled the "Required" checkbox ON.
- On the "Advanced" tab the only thing I changed was to rename Property Name in the Others section from "CurrencyId" to "QuoteCurrencyId"
- I repeated the above steps for the "base" currency navigation property, thus renaming "CurrencyId" to "BaseCurrencyId"
- I clicked "Save and Generate"
ABP, after several seconds, produced this error:
Error occurred on DB migration step! Make sure the project is compiled and working. Command output: Build started... Build failed. Use dotnet build to see the errors.
Using ABP Suite to define an entity with a 1-n navigation property that is flagged as required... It seems that any time I flag a navigation property as "required" ABP Suite will fail to "Save and generate" the code. When it attempts to, I receive the error provided above. Interestingly, If I remove the required flag on these navigation properties, the issue goes away. If I check the "required" box and try again the error comes back. After seeing this error I switched over to Visual Studio and tried to build the solution. This is what I see.
The issue appears to be with this line of generated code:
<Select TValue="Guid"
If I manually change it to:
<Select TValue="Guid?"
... in other words, make it nullable, now the solution builds without errors.
Shouldn't this be defined as Guid?
always, even if the navigation property is required? This is select item for a filter. Although a value for this property is required in the entity definition, it shouldn't be required to filter by this property. Or may there's something I don't understand about this. Please clarify if you can.
At any rate, vanilla code produced by ABP Suite (before any custom modifications) should not produce ABP Suite and build errors... unless I'm doing something wrong. Please advise.
1 Answer(s)
-
0