-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Copy link
Description
Value cannot be null. (Parameter 'derivedType')
at Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType.IsAssignableFrom(IReadOnlyEntityType derivedType)
at System.Linq.Enumerable.<SelectIterator>d__224`2.MoveNext()
at Microsoft.EntityFrameworkCore.Cosmos.Query.Internal.CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.PopulateCollection[TEntity,TCollection](IClrCollectionAccessor accessor, IEnumerable`1 entities)
at Microsoft.EntityFrameworkCore.Cosmos.Query.Internal.CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.AsyncEnumerator.<MoveNextAsync>d__17.MoveNext()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.<SingleOrDefaultAsync>d__16`1.MoveNext()
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.<SingleOrDefaultAsync>d__16`1.MoveNext()
Include your code
public class FilesType
{
public int Id { get; set; }
public bool IsMain { get; set; }
public string? Name { get; set; }
public ICollection<Column>? Columns { get; set; }
public ICollection<Column>? HeadersColumns { get; set; }
}
public class Column
{
public int Id { get; set; }
public string? ColumnName { get; set; }
public bool IsMain { get; set; }
public int ColumnIndex { get; set; }
public int CheckIndex { get; set; }
public string? DateTimeFormat { get; set; }
public string? Description { get; set; }
}
public class ValidationEntityConfiguration : IEntityTypeConfiguration<ValidationSchema>
{
public void Configure(EntityTypeBuilder<ValidationSchema> builder)
{
builder.HasPartitionKey(f => f.Type);
builder.HasKey(f => new { f.Id, f.Enviroment, f.Deleted });
builder.OwnsMany(x => x.Files, files =>
{
files.OwnsMany(om => om.Columns);
files.OwnsMany(om => om.HeadersColumns);
});
}
}
Error occurs on
public ICollection properties? Columns { get; set; }
public ICollection? HeadersColumns { get; set; }
If they are commented out or ef core is 7.013 or lower, the error does not occur
EF Core version: 7.0.14
Database provider: Microsoft.EntityFrameworkCore.Cosmos
Target framework: .net 7
Operating system: Windows 11
IDE: (e.g. Visual Studio 2022 17.8)