Tables without a clustered index are not supported in this version of sql server

I try to do an insert in to n:n (SQL Azure based) related tables (UserSet and TenantSet) using the Entity Framework, but it fails with the error: “tables without a clustered index are not supported in this version of sql server”. I’ve used the model first approach to generate the SQL database, so the SQL Server database should be fine.

After extensive search it seems that the table UserTenant has no clustered index. The script that the Entity Framework generate contains (in my opinion) an error. The relevant part of the script is:

Creating primary key on [User_UserId], [Tenant_TenantId] in table ‘UserTenant’

ALTER
TABLE [dbo].[UserTenant]
ADD
CONSTRAINT [PK_UserTenant]
PRIMARYKEY NONCLUSTERED ([User_UserId], [Tenant_TenantId] ASC);
GO

Of course the NONCLUSTERED parameter should me CLUSTERED. Change that and run the script again.

That’s all, hope the Entity Framework team resolves this what looks like a¬†bug.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>