Skip to content

ToView() equivalent in Data Annotations missing in docs #913

Closed

Description

@carlosmunozrodriguez

Doc says to use .ToView() while using Fluent API but it never says how to do it with Data Annotations


Document Details

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

Activity

  1. ajcvickers commented on Aug 13, 2018

    @ajcvickers
    Contributor

    @carlosmunozrodriguez Data annotations support only a subset of EF Core modeling. For this case I believe you need to use the fluent API. However, I added a note to dotnet/efcore#10111 to consider adding support for attribute mapping in the future.

  2. carlosmunozrodriguez commented on Aug 13, 2018

    @carlosmunozrodriguez
    Author

    Just to add a note. I have successfully used [Table("TableName", Schema = "SchemaName")] to decorate a class that I use with DbQuery<T> to map a View. Although a [View] attribute probably makes more sense.

  3. MonstraG commented on Aug 1, 2023

    @MonstraG

    This was closed in favor of dotnet/efcore#10111 which was closed in favor of dotnet/efcore#10864 which was closed to track these in separate issues (so, in favor of this issue, among the others).

    As a result, this is still missing.

    One way this can be done is to allow null in [Table] annotation.

  4. ErikEJ commented on Aug 1, 2023

    @ErikEJ
    Contributor

    Is it not [Keyless] ?

  5. MonstraG commented on Aug 1, 2023

    @MonstraG

    It still creates a table in the migration, I added [Keyless] and .ToView(null) to prevent that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions