Cannot create more than one clustered index on table

前端 未结 2 1288
北海茫月
北海茫月 2021-02-14 09:25

I am having the following error after typing update-database:

Cannot create more than one clustered index on table \'dbo.AppUsers\'. Drop the existing clu

2条回答
  •  花落未央
    2021-02-14 09:58

    Generally, this error message is caused by not running the Mobile Apps/Mobile Services DB generator. Entity Framework does not have an annotation for creating a clustered index that is not a primary key, so the mobile server SDK manually creates the right SQL statements to set CreatedAt as a non-primary key clustered index.

    To resolve this, run the database generator before migrations are applied. In the Migrations\Configuration.cs file, include the following:

    public Configuration()
    {
       AutomaticMigrationsEnabled = false;
       SetSqlGenerator("System.Data.SqlClient", new EntityTableSqlGenerator());
    }
    

    To learn more, see How to make data model changes to a .NET backend mobile service. The topic applies to both Mobile Services and Mobile Apps, though some namespaces are different in Mobile Apps.

提交回复
热议问题