How to add description to columns in Entity Framework Core code-first using migrations?

c# ef-core-3.0 entity-framework-core

Question

I am using Entity Framework Core 3.0 code. How do I add descriptions for columns in entity configuration classes or migrations so that they end up as a column description in SQL Server?

There is a publication for Entity Framework 4.3.1 but I could not do it in the Entity Framework Core.

1
2
12/27/2019 3:33:08 PM

Popular Answer

You can use HasComment fluent API:

modelBuilder.Entity<MyEntity>()
    .Property(e => e.MyProperty)
    .HasComment("My Column Description");

For SqlServer this is mapped to the corresponding table column description.

1
12/27/2019 3:32:37 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow