Skip to content

Create new entity #1

@OscarCanek

Description

@OscarCanek

Would you help me with the following scenario?

When I add a new entity with a foreign key the keys are not added automatically after I call context.SaveChanges().

class Parent
{
   Guid Id;
   string name;
}

class Child
{
   Parent parent;
   Guid ParentId;
   Guid Id;
   string name;
}

Parent parent = new Parent
{
   Id = Guid.NewGuid(),
   name = "parent"
}

Child child = new Child
{
   Parent = parent,
   Id = Guid.NewGuid(),
   name = "child"
}

context.Childs.Add(child);
context.SaveChanges();

but when I get the ParentId of the child (context.Childs.First().ParentId) the value is null. In EF that behavior do not happen, when I use EF the ParentId property has the guid of the parent.

How can I get the same behavior with this library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions