0

I am building an ASP.NET Core Web API with EF Core 7, and am using a code-first approach. One of my classes has a lambda property TitleNormalized, and I want it to appear as a column in my SQL Server table. When I migrate it, the column does not appear (however, it does appear when the GET request is serialized via OpenAPI).

This is what my class looks like:

[Index(nameof(Title))]
public class Artwork : BaseObject
{
    public string Title { get; set; } = string.Empty;
    public string TitleNormalized => StringExtensions.NormalizeString(Title) ?? string.Empty;
}

public class ArtworkEntityTypeConfiguration : BaseObjectTypeConfiguration<Artwork>
{
    public override void Configure(EntityTypeBuilder<Artwork> builder)
    {
        //// Max Length
        builder
            .Property(b => b.Title)
            .HasMaxLength(500);

        base.Configure(builder);
    }
}

How should I rewrite this so a column gets created and autopopulated in SQL Server?

3
  • @sicon_corn, have you tried like this? stackoverflow.com/questions/46538858/… Commented Dec 2, 2022 at 20:31
  • @RamSingh I'm not sure what I should be focused on in that post. I am able to migrate everything, but the lambda property does not appear as a column in the resulting table. Commented Dec 2, 2022 at 20:34
  • stackoverflow.com/a/46542182/627885 Commented Dec 2, 2022 at 20:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.