Closed cphillips83 closed 2 months ago
can't seem to reproduce it. can you update the following project and send back pls? Repro.zip
could it be possible that your database has some entity which has an array value for the _id
field?
I haven't had time to review this further because someone decided to destroy a 9 node k8s cluster.
There really isn't anything special here as its boiler plate code, the code that creates this single record is done from _001_seed_initial_admin_account.cs
with
namespace Migrations;
public class _001_seed_initial_admin_account : IMigration
{
internal static string SuperAdminPassword { get; set; }
public async Task UpgradeAsync()
{
Console.WriteLine("Creating default super admin");
var user = new Entities.User.Create("test",
"test@test.com",
BCrypt.Net.BCrypt.HashPassword(SuperAdminPassword))
{
IsAdmin = true
};
await new Entities.User(user).SaveAsync();
}
}
Here is the csproj file as well
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<!-- <PublishAot>true</PublishAot> -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FastEndpoints" Version="5.28.0" />
<PackageReference Include="FastEndpoints.Security" Version="5.28.0" />
<PackageReference Include="FastEndpoints.Swagger" Version="5.28.0" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="MongoDB.Entities" Version="23.0.0" />
</ItemGroup>
</Project>
Tomorrow I will try to take your sample project and reproduce it.
Note: I have tried this code repeatedly with a drop database, this is the only collection and record.
I was just going through the fast endpoints example that used monogdb entities and can't get past this error
This is the class in question and the error comes from AsObjectId deserialization, it hits and else and complains that the data type is an array.
I switched to
ObjectIdEntity
and no longer have this issue.Here is the example of the mongo 7 db data...
Error is thrown from
default: