zoukankan      html  css  js  c++  java
  • ABP学习之旅

    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

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

  • 相关阅读:
    操作系统 chapter3 进程线程模型
    操作系统 chapter1 操作系统概述
    操作系统 chapter2 操作系统运行环境
    计算机网络 chapter 9 无线网络
    计算机网络 chapter 10 下一代因特网
    计算机网络 chapter 8 因特网上的音频/视频服务
    汇总常用的jQuery操作Table tr td方法
    jquery判断checkbox是否选中及改变checkbox状态
    $.ajax()方法详解
    wamp设置mysql默认编码
  • 原文地址:https://www.cnblogs.com/WebApp-DotNet/p/8651775.html
Copyright © 2011-2022 走看看