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 '.'.
- CREATE TABLE [dbo].[AspNetUserRoles] ( [UserId] NVARCHAR (128) NOT NULL, [RoleId] NVARCHAR (256) NOT NULL,
- CONSTRAINT [PK_dbo.AspNetUserRoles] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC),
- CONSTRAINT [FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[AspNetRoles] ([Id]) ON DELETE CASCADE,
- CONSTRAINT [FK_dbo.AspNetUserRoles_dbo.AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[AspNetUsers] ([Id]) ON DELETE CASCADE);
- GO
- CREATE NONCLUSTERED INDEX [IX_UserId] ON [dbo].[AspNetUserRoles]([UserId] ASC);
- GO
- CREATE NONCLUSTERED INDEX [IX_RoleId] ON [dbo].[AspNetUserRoles]([RoleId] ASC);
Gowtham RamarPosted Mar 9, 2020, 4:37 AM
Rajanikant HawaldarPosted Mar 9, 2020, 5:03 AM