简体   繁体   English

测试数据库迁移的最佳实践,asp.net core 2.0 + app中的生产服务器

[英]Best practice for Database migration in test , production server in asp.net core 2.0 + app

I am working on a new project which is in asp.net 2.1 web API here I am using Code first migration in local DB 我正在一个新项目中,该项目位于asp.net 2.1 Web API中,我正在本地数据库中使用代码优先迁移

so to deploy my app to test environment I need to know best and safe practice for database migration because this is a new project and in the future daily base there will be a lot of changes may occur 因此,将我的应用程序部署到测试环境中时,我需要了解数据库迁移的最佳和安全做法,因为这是一个新项目,并且在将来的日常工作中,可能会发生很多变化

Best practices are actually provided by Microsoft here 微软实际上在这里提供了最佳实践

Apart from that, this repository provides a good enterprise-level example of how .NET Core Web App/API projects should be written and describes the following practices that help the project scale reliably as the project size grows. 除此之外, 该存储库还提供了一个良好的企业级示例,说明如何编写.NET Core Web App / API项目,并描述了以下实践,这些实践可随着项目规模的扩大可靠地扩展项目。 It is also updated regularly. 它还会定期更新。

  1. Full architecture with responsibility separation concerns, SOLID and Clean Code 具有责任分离问题,SOLID和Clean Code的完整架构
  2. Domain Driven Design (Layers and Domain Model Pattern) 域驱动设计(层和域模型模式)
  3. Domain Events 域事件
  4. Domain Notification 域通知
  5. CQRS (Command Query Responsibility Segregation) CQRS(命令查询职责隔离)
  6. Event Sourcing 活动采购
  7. Unit of Work Repository and Generic Repository 工作单元存储库和通用存储库

Well it sounds like you are mixing migration with deployment. 听起来好像您将迁移与部署混合在一起。 Migration with Code First means making changes in your Data model. 使用Code First进行迁移意味着对数据模型进行更改。 Deploying your code or database to Production is something different. 将代码或数据库部署到生产环境是不同的。 I assume you are referring to deployment in your question. 我假设您是指问题中的部署。 Best way of deployment for both applications and databases is to automate it. 对应用程序和数据库进行部署的最佳方法是使其自动化。 Jenkins, TFS, Teamcity , Octopus are some of the popular CD tools. Jenkins,TFS,Teamcity和Octopus是一些流行的CD工具。 To automate the database deployment you need to write custom libraries. 要自动化数据库部署,您需要编写自定义库。 In one of the companies I worked we check in the DDL script to source code and automated build library drops all the stored procs, functions . 在我工作的一家公司中,我们签入DDL脚本以获取源代码,并且自动构建库删除所有存储的proc,function。 Runs the ddl script and re-creates all the stored procs,functions. 运行ddl脚本并重新创建所有存储的proc,函数。 This way we can be 100% sure all the Environments(QA,Staging, Prod) are in sync . 这样,我们可以100%确保所有Environments(QA,Staging,Prod)都处于同步状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM