Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos: Getting System.ArgumentNullException when loading not primitive collection properties from stored document #19372

Closed
Dragon160 opened this issue Dec 20, 2019 · 1 comment
Labels
area-cosmos closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@Dragon160
Copy link

Description

If I want to store and load the following structure with EntityFrameworkCore.Cosmos I receive an ArgumentNull-Exception saying:

System.ArgumentNullException: Value cannot be null. (Parameter 'arguments[3]')

It seems that the document has been written to the Cosmos DB in the correct form. But it is not possible to read it out again from the DB.

You can find a running sample project showing this issue in my repository:
https://github.com/Dragon160/EntityFrameworkCoreIssue

Code

public class BmwCar
{
    public string Owner { get; set; }
    public int Age { get; set; }
    public string Id { get; set; }

    // Does not work with List
    public IReadOnlyList<EngineInfo> EngineInfos { get; set; }

    // Works with simple property
    //public EngineInfo EngineInfo { get; set; }

    public BmwCar()
    {
        Id = Guid.NewGuid().ToString();
    }
}

public class BmwEngineInfo : EngineInfo
{
    public bool HasXDriveOption { get; set; }

    public Producer Producer { get; set; }
}

public class Producer
{
    public string Name { get; set; }
}

Expected behavior

EFC.Cosmos should be able to read the written document again.

Actual behavior

System.ArgumentNullException: Value cannot be null. (Parameter 'arguments[3]')
when executing

dbContext.BmwCars.Find("id").

Further technical details

EF Core version: 3.1.0 / 3.0.0
Database provider: Cosmos DB
Target framework: Core 3.1 / netStandard2.1
Operating system: Windows 10

@AndriySvyryd
Copy link
Member

AndriySvyryd commented Jun 10, 2020

@Dragon160 Don't call modelBuilder.Entity<BmwEngineInfo>() https://github.com/Dragon160/EntityFrameworkCoreIssue/blob/master/EFCoreCosmosIssue.UnitTests/BmwCosmosDbContext.cs#L23

See #15681 (comment) for how to use configuration classes for owned entity types

Also owned entity types don't support inheritance yet.

@AndriySvyryd AndriySvyryd added closed-no-further-action The issue is closed and no further action is planned. and removed type-bug labels Jun 10, 2020
@AndriySvyryd AndriySvyryd removed their assignment Jun 10, 2020
@AndriySvyryd AndriySvyryd removed this from the 5.0.0 milestone Jun 10, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants