ABP学习之旅
2024-09-09 23:33:09
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
======================================
最新文章
- A new comer playing with Raspberry Pi 3B
- 个人作业-Week3:代码复审
- 使用canvas编写环形图.
- 点透 &; 解决方案
- TextBox
- HD1000A + B Problem
- 关于ActiveMQ的问题分析
- ios 用LLDB查看模拟器文件路径以及一些常用的命令
- 让你的java开发变得如此 Smart
- hdu 5583 Kingdom of Black and White(模拟,技巧)
- Unity UGUI 使用 CCTween 实现 打字效果
- fzu 1909 An Equation(水题)
- 关于reportng生成的测试报告不按测试执行顺序的解决办法
- 启动phpstyle Apache的80端口被win7的System PID=4的进程占用的解决方法
- 【CSS3】动画animation-关键帧keyframes
- ORA-09925: Unable to create audit trail file带来的sqlplus / as sysdba无法连接
- (一一八)利用block实现链式编程
- SpringCloud(5)---Feign服务调用
- Python通过百度Ai识别图片中的文字
- linux命令及用法
热门文章
- abaqus2016安装过程中出现error:unable to add abaqus command directory to PATH variable
- Centos 7 安装composer和Laravel
- vue mock
- springBoot 全局异常方式处理自定义异常 @RestControllerAdvice + @ExceptionHandler
- Django最简单的从请求过程
- Jmeter Distributed (Remote) Testing: Master Slave Configuration
- 【Spring学习】Spring的源码解析之路
- FFmpeg 开发环境搭建及第一个程序 Hello FFmpeg 编写
- paloalto防火墙的优势
- 摘选改善Python程序的91个建议2