带索引的 SimpleRepository 自动迁移
我在开发中使用 subsonic simplerepo 进行迁移,这使事情变得非常简单,但我一直遇到带有索引的 nvarchar 列的问题。出于显而易见的原因,我的用户表在用户名列上定义了一个索引,但每次我启动项目时,亚音速都会执行以下操作:
ALTER TABLE [Users] ALTER COLUMN Username nvarchar(50);
这会导致此问题:
The index 'IX_Username' is dependent on column 'Username'.ALTER TABLE ALTER COLUMN Username failed because one or more objects access this column
有什么办法可以解决此问题吗?
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 failed because one or more objects access this column
Is there any way around this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用哪个数据库管理系统? SQL服务器?
MySQL 从未遇到过这样的问题,但您的 DBMS 似乎不允许更改带有索引的列。这不是 SubSonic 相关的问题。
也许你应该这样做:
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:
这是其中之一或另一个。如果您选择通过 Subsonic 管理数据库(使用迁移),则无法使用索引和其他内容。对不起,伙计。
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.