zoukankan      html  css  js  c++  java
  • ABP数据库的迁移

    添加表,一(Test)对多(Test1)关系

    Test

    using Abp.Domain.Entities.Auditing;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HuamotecHDIS.Entities
    {
        public class Test : FullAuditedEntity
        {
            [Required]
            public bool Enabld { get; set; }
            [Required, MaxLength(200)]
            public byte[] No { get; set; }
            //一对多
            public virtual ICollection<Test1> Test1 { get; set; } 
    
            public Test()
            {
                Test1 = new List<Test1>();
            }
        }
    }
    View Code

    Test1

    using Abp.Domain.Entities.Auditing;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HuamotecHDIS.Entities
    {
        public class Test1 : FullAuditedEntity
        {
            public int TestId{ get; set; }
            public bool Enabld { get; set; }
            public byte[] No { get; set; }
    
            public virtual Test Test { get; set; }
        }
    }
    View Code

    设置数据库配置文件所在位置为启动项,在控制台选择ef层

    执行命令,add-table为生成迁移文件的名称

    add-migration add-table

    更新数据库

    update-database

    生成的数据库

    一对一实体类

     Test

    using Abp.Domain.Entities.Auditing;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HuamotecHDIS.Entities
    {
        public class Test : FullAuditedEntity
        {
            public int Test1Id { get; set; }
            [Required]
            public bool Enabld { get; set; }
            [Required, MaxLength(200)]
            public byte[] No { get; set; }
            //一对一
            public virtual Test1 Test1 { get; set; }
        }
    }
    View Code

    Test1

    using Abp.Domain.Entities.Auditing;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HuamotecHDIS.Entities
    {
        public class Test1 : FullAuditedEntity
        {
            public bool Enabld { get; set; }
            public byte[] No { get; set; }
    
        }
    }
    View Code

    数据库

    删除重新生成表

    1.删除生成的迁移文件

    2.删除生成数据库中的表

    3.删除数据库中的日志记录

  • 相关阅读:
    Ubuntu学习
    MYSQL中group_concat有长度限制!默认1024
    关于Ubuntu中Could not get lock /var/lib/dpkg/lock解决方案
    PHP开发接口使用RSA进行加密解密方法
    WebSocket实战之————Workerman服务器的安装启动
    vim 命令图解
    ubuntu下安装Apache+PHP+Mysql
    Ubuntu 下Apache安装和配置
    android调试输出
    使用AsyncTask异步更新UI界面及原理分析
  • 原文地址:https://www.cnblogs.com/shiruina/p/9298121.html
Copyright © 2011-2022 走看看