Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 473.4k

How can i fix this issue on my query?

Mar 9 2020 4:20 AM
Hi Team
 
I am trying to write this query for AspNetUserRoles, but i am thrown to this exception and need some help. 
 
// Error is  as follows
 
Msg 1753, Level 16, State 0, Line 2
Column 'dbo.AspNetRoles.Id' is not the same length or scale as referencing column 'AspNetUserRoles.RoleId' in foreign key 'FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId'. Columns participating in a foreign key relationship must be defined with the same length and scale.
Msg 1750, Level 16, State 1, Line 2
Could not create constraint or index. See previous errors.
Msg 1088, Level 16, State 12, Line 7
Cannot find the object "dbo.AspNetUserRoles" because it does not exist or you do not have permissions.
Msg 102, Level 15, State 1, Line 16
Incorrect syntax near '.'. 
  1. CREATE TABLE [dbo].[AspNetUserRoles] ( [UserId] NVARCHAR (128) NOT NULL, [RoleId] NVARCHAR (256) NOT NULL,   
  2. CONSTRAINT [PK_dbo.AspNetUserRoles] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC),   
  3. CONSTRAINT [FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[AspNetRoles] ([Id]) ON DELETE CASCADE,   
  4. CONSTRAINT [FK_dbo.AspNetUserRoles_dbo.AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[AspNetUsers] ([Id]) ON DELETE CASCADE);  
  5. GO  
  6. CREATE NONCLUSTERED INDEX [IX_UserId] ON [dbo].[AspNetUserRoles]([UserId] ASC);  
  7. GO  
  8. CREATE NONCLUSTERED INDEX [IX_RoleId] ON [dbo].[AspNetUserRoles]([RoleId] ASC);  
 

Answers (2)