杨中科视频结业
一、添加环境变量,配置数据库链接
变量名:DefaultDB:ConnStr
变量值:您的数据库链接字符串
二、迁移数据库
Infrastructure结尾的项目需要迁移数据库(SearchService.Infrastructure除外)实际共计四个项目
删除Migrations文件夹自己重新生成请使用
Add-Migration
Update-database
不删除直接更新请使用
Update-database
遇到的问题
报错一:Your startup project 'Listening.Infrastructure' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
解决:引用Microsoft.EntityFrameworkCore.Design
报错二:Unable to create an object of type 'ListeningDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
解决:在每个Infrastructure项目中添加(复制,不知道为啥作者的放在了API项目中,我的就不行,有知道的老铁留言告诉一下,见附录一)一个DesignTimeDbContextFactory,修改为当前项目的DbContext,并设置Infrastructure为启动项目。
并引用通用项目CommonInitializer
升级nuget包
三、手动添加 T_Configs 表
Id | Name | Value |
---|---|---|
1 | Cors | {"Origins":["http://localhost:3000","https://localhost:5011","https://localhost:5001","https://localhost:5021","https://localhost:5031","https://localhost:5041","https://localhost:7199"]} |
2 | FileService:SMB | {"WorkingDir":"d:/temp/upload/"} |
3 | Redis | {"ConnStr":"192.168.100.6"} |
4 | RabbitMQ | {"HostName":"192.168.100.6","ExchangeName":"amvig_event_bus","UserName":"admin","Password":"admin","Port":"5672","VirtualHost":"VH01"} |
5 | ElasticSearch | {"Url":"http://elastic:[email protected]:9200/"} |
6 | JWT | {"Issuer":"zack","Audience":"zack","Key":"sldfjsdfjisdflsdfjl@jfelfi323lsfj","ExprireSeconds":31536000} |
四、RabbitMQ
因为使用了不同的服务器,所以不能使用默认的guest账号(guest默认只能本机登陆)
添加一个admin账号,administrator组,添加一个virtual hosts,命名为VH01,并且Set Permission给admin访问权限(应该也可以不用创建VH01,但是要给新用户根目录的权限),该账号就可以远程访问
IntegrationEventRabbitMQOptions类增加属性:Port、VirtualHost,并在T_Configs表中修改配置
{"HostName":"192.168.1.6","ExchangeName":"zack_event_bus","UserName":"admin","Password":"admin","Port":"5672","VirtualHost":"VH01"}
其中ExchangeName不需要在RabbitMQ中配置,在程序中配置就可以了
附录一
根据视频下的留言推论
DesignTimeDbContextFactory可以放在API项目中,此时API项目要设置为启动项目
Visualstudio 选择启动项目为api, 程序包管理控制台 选择Infrastructure基础设施层
未测试,仅备查!
标签:Infrastructure,本地,项目,admin,192.168,localhost,https,源代码,调试 From: https://www.cnblogs.com/djd66/p/16899185.html