1、我使用ABP的启动模板(http://www.aspnetboilerplate.com/Templates)来创建一个Web应用程序。

2、加载项目解决方案

  在abp根据模板创建解决方案后,编译报错,提示某个包的版本不对。
  解决方案:https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json

  

3、在.Core中创建entity

  生成poco实体类的工具:EntityFramework Reverse POCO Generator,可以根据数据库生成具有DataAnnotations的实体类:
  可以通过vs的扩展安装,也可以通过这个地址:https://marketplace.visualstudio.com/items?itemName=SimonHughes.EntityFrameworkReversePOCOGenerator#qna
  生成DataAnnotations特性,需要在T4中做如下设置更改:

  • Settings.ConnectionStringName = "Test"; // Searches for this connection string in config files listed below in the ConfigFilenameSearchOrder setting
  • Settings.UseDataAnnotations = true; // If true, will add data annotations to the poco classes.
  • Settings.UseDataAnnotationsSchema = true; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
  • 在dataAnnotation上加长字段长度,针对char和varcahr:
      if (Settings.UseDataAnnotations)
{
if(c.Ordinal > 1 && !commentWritten)
WriteLine(string.Empty); // Leave a blank line before the next property foreach (var dataAnnotation in c.DataAnnotations)
{
//将char、varchar的dataAnnotation上加上长度,如varchar(10),以兼容.net core
if(dataAnnotation.ToString().StartsWith("Column"))
{
if(dataAnnotation.ToString().Contains("varchar"))
WriteLine(" [" + dataAnnotation.ToString().Replace("varchar","varchar("+c.MaxLength+")") + "]");
else if(dataAnnotation.ToString().Contains("char"))
WriteLine(" [" + dataAnnotation.ToString().Replace("char","char("+c.MaxLength+")")+ "]");
}
else
{
WriteLine(" [" + dataAnnotation + "]");
} }
}

4、方法EntityFramworkCore的DBContext增加DBSet

======================================

Add-Migration "Initial"

update-database

======================================

最新文章

  1. A new comer playing with Raspberry Pi 3B
  2. 个人作业-Week3:代码复审
  3. 使用canvas编写环形图.
  4. 点透 & 解决方案
  5. TextBox
  6. HD1000A + B Problem
  7. 关于ActiveMQ的问题分析
  8. ios 用LLDB查看模拟器文件路径以及一些常用的命令
  9. 让你的java开发变得如此 Smart
  10. hdu 5583 Kingdom of Black and White(模拟,技巧)
  11. Unity UGUI 使用 CCTween 实现 打字效果
  12. fzu 1909 An Equation(水题)
  13. 关于reportng生成的测试报告不按测试执行顺序的解决办法
  14. 启动phpstyle Apache的80端口被win7的System PID=4的进程占用的解决方法
  15. 【CSS3】动画animation-关键帧keyframes
  16. ORA-09925: Unable to create audit trail file带来的sqlplus / as sysdba无法连接
  17. (一一八)利用block实现链式编程
  18. SpringCloud(5)---Feign服务调用
  19. Python通过百度Ai识别图片中的文字
  20. linux命令及用法

热门文章

  1. abaqus2016安装过程中出现error:unable to add abaqus command directory to PATH variable
  2. Centos 7 安装composer和Laravel
  3. vue mock
  4. springBoot 全局异常方式处理自定义异常 @RestControllerAdvice + @ExceptionHandler
  5. Django最简单的从请求过程
  6. Jmeter Distributed (Remote) Testing: Master Slave Configuration
  7. 【Spring学习】Spring的源码解析之路
  8. FFmpeg 开发环境搭建及第一个程序 Hello FFmpeg 编写
  9. paloalto防火墙的优势
  10. 摘选改善Python程序的91个建议2