EntityFramework.DbDescriptionHelper,ef tool for generating database tables and columns description (SqlServer only for now)
- Add Attribute
// TableName equals the model's Name
[TableDescription("UserTable")]
public class User : BaseModel
{
[ColumnDescription("Username")]
public string Username { get; set; }
/// <summary>
/// 密码
/// </summary>
[ColumnDescription("PasswordHash")]
public string PasswordHash { get; set; }
[ColumnDescription("IsActive")]
public bool IsActive { get; set; }
}
// table name not equals the model's Name
[TableDescription("ShopRouteInfo", "RouteInfoTable")]
public class ShopRouteInfoModel:BaseModel
{
[ColumnDescription("RouteType,0:Area,1:Controller,2:Action")]
public int RouteType { get; set; }
[ColumnDescription("RouteInfoName")]
public string RouteInfoName { get; set; }
[ColumnDescription("RouteInfoDesc")]
public string RouteInfoDesc { get; set; }
[ColumnDescription("Parent RouteInfo")]
public int ParentId { get; set; }
}
- Add custom database initializer
please refer to the samples below
- Generate database description
// Generate databse description directly
new SqlServerDbDescriptionInitializer().GenerateDbDescription(context);
// Generate database description directly async
await new SqlServerDbDescriptionInitializer().GenerateDbDescriptionAsync(context);
// generate create databse description sql text
new SqlServerDbDescriptionInitializer().GenerateDbDescriptionSqlText(typeof(context));
.net framework project url: https://github.com/WeihanLi/AccessControlDemo
asp.net core project: https://github.com/WeihanLi/AccountingApp
What will be done in the release V1.0
- Get table name automatically
- Get column name automatically
You can contact me via weihanli@outlook.com whenever you have a problem about this project.