Skip to content

Ignoring properties in an owned type using fluent API #1457

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

Closed
coder925 opened this issue May 7, 2019 · 1 comment · Fixed by #1906
Closed

Ignoring properties in an owned type using fluent API #1457

coder925 opened this issue May 7, 2019 · 1 comment · Fixed by #1906

Comments

@coder925
Copy link

coder925 commented May 7, 2019

How should one ignore properties in an owned type using fluent call? I have figured out how to do this with attributes by adding [NotMapped] to the property, but not how the same is done using Fluent API.

In EF 6 I was able to ignore properties on a complex type like this:
modelBuilder.ComplexType<StreetAddress>().Ignore(a => a.City);

In EF Core 2.2, it is possible to define the type but not continue with Ignore:
modelBuilder.Owned<StreetAddress>();

The by-design restrictions tell me I cannot do this:
modelBuilder.Entity<StreetAddress>().Ignore(a => a.City);

I think it would be helpful with a section in the documentation of Owned Entity Types about ignoring properties in an owned type using both attributes and fluent API.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@AndriySvyryd
Copy link
Member

Currently it's only possible to do for a specific reference.

modelBuilder.Entity<Order>().OwnsOne(
    o => o.ShippingAddress,
    sa =>
    {
        sa.Ignore(p => p.City);
    });

@AndriySvyryd AndriySvyryd modified the milestones: Backlog, 3.1.0 Nov 6, 2019
AndriySvyryd added a commit that referenced this issue Nov 6, 2019
AndriySvyryd added a commit that referenced this issue Nov 10, 2019
AndriySvyryd added a commit that referenced this issue Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants