-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Owned Types: SaveChanges fails on Relational but succeeds for In-memory #8907
Comments
Make the columns nullable for dependent types involved in table splitting. When uniquifying column names use the declaring entity type name as prefix. Fixes #8907
Make the columns nullable for dependent types involved in table splitting. When uniquifying column names use the declaring entity type name as prefix. Fixes #8907
Make the columns nullable for dependent types involved in table splitting. When uniquifying column names use the declaring entity type name as prefix. Fixes #8907
Make the columns nullable for dependent types involved in table splitting. When uniquifying column names use the declaring entity type name as prefix. Fixes #8907
oh I think this is what I've been beating my head on today! InMemory was ok but integration tests against SQL Server db fail Using preview2-final and trying to add an object (samurai) that has a SecrectIdentity property that is valueobject defined in fluent API as OwnsOne. Error is almost the same as the error in this issue: There are '2' entity types sharing the table 'Samurais', but only '1' entries Is that what I'm hitting? The Owned type isn't an entity so there should only be one entity. Here's my stack trace ... Stack Trace:
|
updated packages to preview3-* and still having this problem. Now I'm wondering if it's related to #8986 which isn't merged yet? If not, I can create a new issue. |
@julielerman Could you file an issue with a full listing or project that reproduces what you are seeing? |
will do! May have to wait until end of week (conference) I'll also recheck after 8986 is merged. |
@julielerman Owned entities are still entities. And owned entities are not optional when using table splitting (the default) |
Sorry, I thought that without an ID, it isn't an entity. (DDD & old-EF complex type assumptions) |
I just retested with preview3-* and rtm-* (currently rtm-26180) and still getting this problem. The owned entity is not null as mentioned earlier. I will open a separate repo and link to this for ref. Just have to create a trimmed down, focused solution. |
@AndriySvyryd re your explanation that "owned entities are not optional when using table splitting (the default)" What alternatives are there (non default)? I do expect the values of the value object to be stored in the same table as the entity that uses that object as a property so not sure how else to do that without table splitting. The fact that the owned entity is not optional creates some other types of problems for how I would design my domain model following DDD guidance. For one there's no chance to have null objects. Even if I default the property to having each of it's values null, I would have to do some unconventional logic be able to test for a null object (e.g. test that every property of the value object is null and that creates more complexities with value types like int). Am I missing something or is this just the way it is right now? Is there any plan to change this going forward? Shall I create an issue that you can mark as enhancement? |
@julielerman The fundamental problem with optional dependents using table splitting is differentiating between a non-existent dependent and one with all non-PK properties having default values. public class Customer
{
public int Id { get; set; }
public Address Address { get; set; }
}
public class Address
{
public int Id { get; set; }
public string Street { get; set; }
} And they are mapped to the same table with columns For now any dependents using table splitting are required. To make a navigation to an owned type optional you would have to map it to a different table. |
I hadn't discovered #9005. That is most excellent! I totally grok the challenges you have! Now I can use my little workaround but also share with folks know this will get easier! Thanks @AndriySvyryd ! :) |
Given the following:
The SaveChanges call throws on relational:
But, In-memory is able to persist the data correctly.
The text was updated successfully, but these errors were encountered: