定义亚音速3 ActiveRecord的迁移 [英] Defining SubSonic 3 ActiveRecord migrations

查看:114
本文介绍了定义亚音速3 ActiveRecord的迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用亚音速3 ActiveRecord的一个ASP.NET MVC项目。我添加了一个表的用户具有主键ID和重新编译T4文件生成用户类别。

I'm starting an ASP.NET MVC project using SubSonic 3 ActiveRecord. I added a table Users with a primary key ID and recompiled T4 files to generate User class.

我想确保,因为我去随着时代的发展,我可以再生/数据库在任何时候迁移。它看起来像我要在数据库中创建表和关系,再生ActiveRecord的班,做移民在 HTTP描述: //subsonicproject.com/docs/3.0_Migrations 的。确定迁移的旧2.x的方式似乎并没有提供任何更多。

I want to make sure that, as I go along with the development, I can regenerate/migrate the database at any point. It looks like I have to create tables and relationships in the database, regenerating ActiveRecord classes and doing migration as described in http://subsonicproject.com/docs/3.0_Migrations. The old 2.x way of defining migrations doesn't seem to be available any more.

有没有办法开车从code ++开发,而不是数据库中,通过更改模型类,并有数据库迁移因此,不使用SimpleRepository?我不想把生成code到源$ C ​​$ C库,但如果我不这样做,我失去了数据库模式(除非我出口和手动保存)。

Is there a way to drive development from the code rather than database, by changing model classes, and have the database migrated accordingly, without using SimpleRepository? I don't want to put generated code into source code repository, but if I don't, I lose database schema (unless I export and save it manually).

推荐答案

您仍可以使用亚音速3作为DAL,让亚音速2.2生成的迁移为您服务。 你只需要sonic.exe和它的相关性来执行迁移文件。

You can still use SubSonic 3 as a DAL and let SubSonic 2.2 generate the migrations for you. You just need sonic.exe and it's dependencies to execute the migration files.

要更precise,我的文件夹迁移在我DataLayer项目,保持所有的迁移文件,但设置的BuildAction无法比拟的。所以,我有语法高亮(但没有错误检查,除非我设置的BuildAction回编译),但code不惹我的项目。

To be more precise, I have folder Migrations in my DataLayer Project, that keeps all the migration Files but set the BuildAction to none. So I have Syntax Highlighting (but no error checking unless I set BuildAction back to compile) but the code does not mess my project.

您可以保留,当然他们在自己的项目。但是我喜欢这样的方式,有它在版本控制下,并确保我目前DAL是匹配我的移动版。

You can keep them in an own project, of course. But I like it this way to have it under version control and be sure that my current DAL is matching my migration version.

另外,我有一个名为我的配置文件migration.config(而不是App.config中/ web.config中),并使用此命令行来执行我的迁移。

In addition, I have named my config file migration.config (instead of app.config/web.config) and use this commandline to execute my migrations.

Command:           /path/to/sonic.exe  
Arguments:         migrate /config migration.config
Working Directory: $(SolutionDir)MyProject.Datalayer

请注意/配置开关来覆盖配置文件sonic.exe所期待的。

Notice the /config switch to override the config file sonic.exe is looking for.

这篇关于定义亚音速3 ActiveRecord的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆