Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core asp net核心创建自己生成的迁移,如rails_Asp.net Core - Fatal编程技术网

Asp.net core asp net核心创建自己生成的迁移,如rails

Asp.net core asp net核心创建自己生成的迁移,如rails,asp.net-core,Asp.net Core,是否有在asp net项目中手动创建迁移的方法?生成空迁移文件并添加将更改数据库结构的代码 在asp net核心中: 改变模式 class Product { public string PartNumber { get; set; } } dotnet ef migrations add MyMigration->它将检查模型并自动生成迁移 在RubyonRails中 rails生成迁移MyMigration 编写迁移 class AddPartNumberToProducts &

是否有在asp net项目中手动创建迁移的方法?生成空迁移文件并添加将更改数据库结构的代码

在asp net核心中:

  • 改变模式

    class Product
    {
        public string PartNumber { get; set; }
    }
    
  • dotnet ef migrations add MyMigration->它将检查模型并自动生成迁移

  • 在RubyonRails中

  • rails生成迁移MyMigration
  • 编写迁移

    class AddPartNumberToProducts < ActiveRecord::Migration[5.0]
        def up
            add_column :products, :part_number, :string
        end
    end
    
    class AddPartNumberToProducts

  • 我更喜欢Rails方式…

    您仍然可以修改ef migrations add命令生成的迁移。或者你的问题是什么?我想使用迁移,但我想自己编写所有迁移,而不需要EF自动检查模型类。