Skip to content

CUSTIS-public/EFCore.DbComments

Repository files navigation

EFCore.DbComment

latest version downloads

Add comment for objects (table, column) from code to database. You can use it with xml comment summary or Description clr attr.

Using comments from XmlDoc

/// <summary>User</summary>
public class User
{
    /// <summary>Full name</summary>
    public string Name { get; set; }
}

In DbContext.OnModelCreating(ModelBuilder builder) insert

modelBuilder.CommentModelFromXml();

And then you can do dotnet ef migrations add ...

Don't forget to enable XML documentation

Using comments from [Description] attr

[Description("User")]
public class User
{
    [Description("Full name")]
    public string Name { get; set; }
}

In DbContext.OnModelCreating(ModelBuilder builder) insert

modelBuilder.CommentModelFromDescriptionAttr();

XmlDoc from nuget packages

If you inherit entities from classes from nuget packages, you should also enable packaging xml documentation in packages and enable copying their documentation to output directory.

Coping XmlDoc from nuget package to output directory

To copy XmlDocs, you need to add section to your startup project .csproj or Directory.Build.props:

   <Target Name="_ResolveCopyLocalNuGetPackagePdbsAndXml" Condition="$(CopyLocalLockFileAssemblies) == true" AfterTargets="ResolveReferences">
       <ItemGroup>
           <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).xml')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).xml')" />
       </ItemGroup>
   </Target>

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages