Running Azure Mobile Server project locally

独自空忆成欢 提交于 2019-12-08 06:43:06

问题


I'm running an Azure Mobile Server project locally with a local SQL Database. I started from the Quickstart project, but as soon as I change the Entity to something more complex, I get this error with my migration:

"Cannot create more than one clustered index on table..."

Even with the correct schema I get this other error:

"Automatic migrations that affect the location of the migrations history system table (such as default schema changes) are not supported. Please use code-based migrations for operations that affect the location of the migrations history system table."


回答1:


If you're using migrations, there's a chance that EF is trying to create both the primary key and CreatedAt column as clustered indexes. If you tell the migration to use the Azure Mobile Services/Apps SqlGenerator, it should do the right thing.

See if my answer here fixes the issue for you.




回答2:


This is an artifact of Entity Framework, the ORM that .NET Mobile Services use. It's recommended that you use Code First Migrations to address this issue. Mobile Services has a full guide which is kept up to date on how to enable code first migrations. https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-how-to-use-code-first-migrations/

If you'd rather not deal with Code First Migrations, you can drop your database each time (not really a good idea for production purposes) or use the JavaScript backend.



来源:https://stackoverflow.com/questions/31953101/running-azure-mobile-server-project-locally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!