Lapiniot / Net.MQTT

0 stars 0 forks source link

Make Mqtt.Server.Identity project backward compatible with .NET8, so it can target both net8.0 & net9.0 #24

Closed Lapiniot closed 3 days ago

Lapiniot commented 4 days ago

What we have at the moment:

  1. Microsoft.AspNetCore.Identity.EntityFrameworkCore v9.0.0 is not compatible with .NET 8 (targets latest version of the runtime). Thus we must use previous v.8.0.* version of the library which targets .NET 8. This can be achieved via conditional \ project items with version override.
  2. EF9 is generally compatible with .NET 8 and can work even with prev. versions of entity types from the Microsoft.AspNetCore.Identity.EntityFrameworkCore.
  3. Currently used compiled model, built with --nativeaot flag enabled, heavily uses [UnsafeAccessor] feature instead of reflection for private code access. This approach somehow breaks in runtime for older version of Identity-related entity types. We either need to revert to the older reflection-based compiled model globally or use it conditionally for legacy entity type version.
Lapiniot commented 4 days ago

[!IMPORTANT] Alternative reflection-based model can be built with: dotnet-ef dbcontext optimize --framework=net8.0 --msbuildprojectextensionspath=../artifacts/obj/Mqtt.Server.Identity --output-dir=./Data/Compiled --suffix=.V8