fjykTec / ModernWMS

The open source simple and complete warehouse management system is derived from our many years of experience in implementing erp projects. We stripped the original commercial system wms function and opened it up for free, hoping to help the majority of small and medium-sized enterprises. At present, the system supports cross-platform。
https://modernwms.ikeyly.com/
Apache License 2.0
874 stars 273 forks source link

dotnet ef migrations error #16

Open maketochen opened 1 year ago

maketochen commented 1 year ago

请问这个迁移如何操作 cd ModernWMS dotnet ef migrations add init Build started... Build succeeded. Your target project 'ModernWMS' doesn't match your migrations assembly 'ModernWMS.Core'. Either change your target project or change your migrations assembly. Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("ModernWMS")). By default, the migrations assembly is the assembly containing the DbContext. Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project. cd .\ModernWMS.Core\ Unable to create an object of type 'SqlDBContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

JawerZ commented 1 year ago

报错中已提及,项目的DBContext在ModernWMS.Core下,所以迁移时需要以ModernWMS.Core为目标项目,对应依赖包在Core项目下需要有,不过我看您已经切换使用SQLServer了为何还要做迁移,常用的数据库初始化脚本都已上传至本项目您可以看一下是否有您需要的。

maketochen commented 1 year ago

该问题已解决,就是在初次迁移的时候 如果数据库已存在表,就是会报错,需要注释掉up方法里的代码