开发者

SimpleRepository auto migrations with indexes

I am using subsonic simplerepo with migrations in dev and it makes things pretty easy but I keep running into issues with my nvarchar columns that have an index. My users table has an index defined on the username column for obvious reasons but each time I start the project subsonic is doing this:

ALTER TABLE [Users] ALTER COLUMN Username nvarchar(50);

which causes this:

The index 'IX_Username' is dependent on column 'Username'.ALTER TABLE ALTER COLUMN Username fai开发者_JS百科led because one or more objects access this column

Is there any way around this issue?


Which DBMS are you using? Sql Server?

Never had a problem like this with MySQL, but it seems that your DBMS does not allow to alter a column with an index on it. This is not a SubSonic related issue.

Maybe you should do:

Execute("DROP index ...");
AlterColumn("...");
Execute("CREATE index ...");


It is one or the other. If you choose to manage your DB by Subsonic (use migrations), you can't use indexes and stuff. Sorry mate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜