Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Unable to seed multiple roles in database

$
0
0

Hi all, 

I'm new to .net core and I trying to develop an web app (using angular template by default) with seeding database function. I successfully create other custom model records with entity framework while seeding the database but not IdentityRole model (which using roleStore)

This is my code using in seed function, given GetDefaultRoles() is return List<string> type, with data = System Admin, Moderator and Viewer

public class DbInitializer{ 
public static async Task Initialize(Context context)
{
...
RoleStore<IdentityRole> roleStore = new RoleStore<IdentityRole>(context); foreach (string roleName in GetDefaultRoles()) { if (!context.Roles.Any(r => r.Name == roleName)) { await roleStore.CreateAsync(new IdentityRole() { Name = roleName, NormalizedName = roleName.ToUpper() }); } }
...
}
}

Main function in Program.cs
using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context= services.GetRequiredService<Context>();
                    var result = DBInitializer.Initialize(context);
                }
                catch (Exception exception)
                {
                       //Write in Error log file
                }
            }


Every time I run the code to create new database, only the first record(System Admin) is inserted. Then I rebuild app and run again with the database is already created, second record (Moderator) is inserted and the third time then only insert the last record (viewer). 

Or some time in the first time run, the first 2 record is inserted but not the viewer record. I also increase the connection timeout, but not help. 

I debug the code and found after first time roleStore.CreateAsync is executed, the next loop will stop at if condition line and jump to Index() in HomeController. 

I also recheck the output of ASP.Net core web server, the below is the output for the first time build without database, it clearly stated the insert statement of Role record only execute one time. 

 info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
       User profile is available. Using 'C:\Users\wychan\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
 info: Microsoft.EntityFrameworkCore.Infrastructure[100403]
       Entity Framework Core 2.0.0-rtm-26452 initialized 'ClaimContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (759ms) [Parameters=[], CommandType='Text', CommandTimeout='60']
       CREATE DATABASE [Inteksoft_Claim_Dev];
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (560ms) [Parameters=[], CommandType='Text', CommandTimeout='60']
       IF SERVERPROPERTY('EngineEdition') <> 5 EXEC(N'ALTER DATABASE [Inteksoft_Claim_Dev] SET READ_COMMITTED_SNAPSHOT ON;');
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (61ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetRoles] (
           [Id] nvarchar(450) NOT NULL,
           [ConcurrencyStamp] nvarchar(max) NULL,
           [Name] nvarchar(256) NULL,
           [NormalizedName] nvarchar(256) NULL,
           CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetUsers] (
           [Id] nvarchar(450) NOT NULL,
           [AccessFailedCount] int NOT NULL,
           [ConcurrencyStamp] nvarchar(max) NULL,
           [Email] nvarchar(256) NULL,
           [EmailConfirmed] bit NOT NULL,
           [LockoutEnabled] bit NOT NULL,
           [LockoutEnd] datetimeoffset NULL,
           [NormalizedEmail] nvarchar(256) NULL,
           [NormalizedUserName] nvarchar(256) NULL,
           [PasswordHash] nvarchar(max) NULL,
           [PhoneNumber] nvarchar(max) NULL,
           [PhoneNumberConfirmed] bit NOT NULL,
           [SecurityStamp] nvarchar(max) NULL,
           [TwoFactorEnabled] bit NOT NULL,
           [UserName] nvarchar(256) NULL,
           CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id])
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [ExpenseCategory] (
           [ExpenseCategoryId] int NOT NULL IDENTITY,
           [DateTimeCreated] datetime2 NOT NULL,
           [DateTimeDeleted] datetime2 NOT NULL,
           [DateTimeUpdated] datetime2 NOT NULL,
           [Description] nvarchar(max) NULL,
           [ExpenseCategoryName] nvarchar(100) NULL,
           [IsDeleted] bit NOT NULL,
           [ShowExpenseTypeInSummary] bit NOT NULL,
           CONSTRAINT [PK_ExpenseCategory] PRIMARY KEY ([ExpenseCategoryId])
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetRoleClaims] (
           [Id] int NOT NULL IDENTITY,
           [ClaimType] nvarchar(max) NULL,
           [ClaimValue] nvarchar(max) NULL,
           [RoleId] nvarchar(450) NOT NULL,
           CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]),
           CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetUserClaims] (
           [Id] int NOT NULL IDENTITY,
           [ClaimType] nvarchar(max) NULL,
           [ClaimValue] nvarchar(max) NULL,
           [UserId] nvarchar(450) NOT NULL,
           CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]),
           CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetUserLogins] (
           [LoginProvider] nvarchar(450) NOT NULL,
           [ProviderKey] nvarchar(450) NOT NULL,
           [ProviderDisplayName] nvarchar(max) NULL,
           [UserId] nvarchar(450) NOT NULL,
           CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]),
           CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetUserRoles] (
           [UserId] nvarchar(450) NOT NULL,
           [RoleId] nvarchar(450) NOT NULL,
           CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]),
           CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE NO ACTION,
           CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (18ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [AspNetUserTokens] (
           [UserId] nvarchar(450) NOT NULL,
           [LoginProvider] nvarchar(450) NOT NULL,
           [Name] nvarchar(450) NOT NULL,
           [Value] nvarchar(max) NULL,
           CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]),
           CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE TABLE [ExpenseType] (
           [ExpenseTypeId] int NOT NULL IDENTITY,
           [DateTimeCreated] datetime2 NOT NULL,
           [DateTimeDeleted] datetime2 NOT NULL,
           [DateTimeUpdated] datetime2 NOT NULL,
           [Description] nvarchar(max) NULL,
           [ExpenseCategoryId] int NOT NULL,
           [ExpenseTypeName] nvarchar(100) NULL,
           [IsDeleted] bit NOT NULL,
           CONSTRAINT [PK_ExpenseType] PRIMARY KEY ([ExpenseTypeId]),
           CONSTRAINT [FK_ExpenseType_ExpenseCategory_ExpenseCategoryId] FOREIGN KEY ([ExpenseCategoryId]) REFERENCES [ExpenseCategory] ([ExpenseCategoryId]) ON DELETE NO ACTION
       );
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL;
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL;
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       CREATE INDEX [IX_ExpenseType_ExpenseCategoryId] ON [ExpenseType] ([ExpenseCategoryId]);
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       SELECT CASE
           WHEN EXISTS (
               SELECT 1
               FROM [ExpenseCategory] AS [e])
           THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
       END
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (33ms) [Parameters=[@p0='?', @p1='?', @p2='?', @p3='?' (Size = 4000), @p4='?' (Size = 100), @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?' (Size = 4000), @p11='?' (Size = 100), @p12='?', @p13='?', @p14='?', @p15='?', @p16='?', @p17='?' (Size = 4000), @p18='?' (Size = 100), @p19='?', @p20='?', @p21='?', @p22='?', @p23='?', @p24='?' (Size = 4000), @p25='?' (Size = 100), @p26='?', @p27='?', @p28='?', @p29='?', @p30='?', @p31='?' (Size = 4000), @p32='?' (Size = 100), @p33='?', @p34='?', @p35='?', @p36='?', @p37='?', @p38='?' (Size = 4000), @p39='?' (Size = 100), @p40='?', @p41='?', @p42='?', @p43='?', @p44='?', @p45='?' (Size = 4000), @p46='?' (Size = 100), @p47='?', @p48='?', @p49='?', @p50='?', @p51='?', @p52='?' (Size = 4000), @p53='?' (Size = 100), @p54='?', @p55='?', @p56='?', @p57='?', @p58='?', @p59='?' (Size = 4000), @p60='?' (Size = 100), @p61='?', @p62='?', @p63='?', @p64='?', @p65='?', @p66='?' (Size = 4000), @p67='?' (Size = 100), @p68='?', @p69='?', @p70='?', @p71='?', @p72='?', @p73='?' (Size = 4000), @p74='?' (Size = 100), @p75='?', @p76='?', @p77='?', @p78='?', @p79='?', @p80='?' (Size = 4000), @p81='?' (Size = 100), @p82='?', @p83='?'], CommandType='Text', CommandTimeout='30']
       SET NOCOUNT ON;
       DECLARE @inserted0 TABLE ([ExpenseCategoryId] int, [_Position] [int]);
       MERGE [ExpenseCategory] USING (
       VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, 0),
       (@p7, @p8, @p9, @p10, @p11, @p12, @p13, 1),
       (@p14, @p15, @p16, @p17, @p18, @p19, @p20, 2),
       (@p21, @p22, @p23, @p24, @p25, @p26, @p27, 3),
       (@p28, @p29, @p30, @p31, @p32, @p33, @p34, 4),
       (@p35, @p36, @p37, @p38, @p39, @p40, @p41, 5),
       (@p42, @p43, @p44, @p45, @p46, @p47, @p48, 6),
       (@p49, @p50, @p51, @p52, @p53, @p54, @p55, 7),
       (@p56, @p57, @p58, @p59, @p60, @p61, @p62, 8),
       (@p63, @p64, @p65, @p66, @p67, @p68, @p69, 9),
       (@p70, @p71, @p72, @p73, @p74, @p75, @p76, 10),
       (@p77, @p78, @p79, @p80, @p81, @p82, @p83, 11)) AS i ([DateTimeCreated], [DateTimeDeleted], [DateTimeUpdated], [Description], [ExpenseCategoryName], [IsDeleted], [ShowExpenseTypeInSummary], _Position) ON 1=0
       WHEN NOT MATCHED THEN
       INSERT ([DateTimeCreated], [DateTimeDeleted], [DateTimeUpdated], [Description], [ExpenseCategoryName], [IsDeleted], [ShowExpenseTypeInSummary])
       VALUES (i.[DateTimeCreated], i.[DateTimeDeleted], i.[DateTimeUpdated], i.[Description], i.[ExpenseCategoryName], i.[IsDeleted], i.[ShowExpenseTypeInSummary])
       OUTPUT INSERTED.[ExpenseCategoryId], i._Position
       INTO @inserted0;

       SELECT [t].[ExpenseCategoryId] FROM [ExpenseCategory] t
       INNER JOIN @inserted0 i ON ([t].[ExpenseCategoryId] = [i].[ExpenseCategoryId])
       ORDER BY [i].[_Position];
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
       SELECT CASE
           WHEN EXISTS (
               SELECT 1
               FROM [ExpenseType] AS [e])
           THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
       END
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (31ms) [Parameters=[@p0='?', @p1='?', @p2='?', @p3='?' (Size = 4000), @p4='?', @p5='?' (Size = 100), @p6='?', @p7='?', @p8='?', @p9='?', @p10='?' (Size = 4000), @p11='?', @p12='?' (Size = 100), @p13='?', @p14='?', @p15='?', @p16='?', @p17='?' (Size = 4000), @p18='?', @p19='?' (Size = 100), @p20='?', @p21='?', @p22='?', @p23='?', @p24='?' (Size = 4000), @p25='?', @p26='?' (Size = 100), @p27='?', @p28='?', @p29='?', @p30='?', @p31='?' (Size = 4000), @p32='?', @p33='?' (Size = 100), @p34='?', @p35='?', @p36='?', @p37='?', @p38='?' (Size = 4000), @p39='?', @p40='?' (Size = 100), @p41='?', @p42='?', @p43='?', @p44='?', @p45='?' (Size = 4000), @p46='?', @p47='?' (Size = 100), @p48='?', @p49='?', @p50='?', @p51='?', @p52='?' (Size = 4000), @p53='?', @p54='?' (Size = 100), @p55='?', @p56='?', @p57='?', @p58='?', @p59='?' (Size = 4000), @p60='?', @p61='?' (Size = 100), @p62='?', @p63='?', @p64='?', @p65='?', @p66='?' (Size = 4000), @p67='?', @p68='?' (Size = 100), @p69='?', @p70='?', @p71='?', @p72='?', @p73='?' (Size = 4000), @p74='?', @p75='?' (Size = 100), @p76='?', @p77='?', @p78='?', @p79='?', @p80='?' (Size = 4000), @p81='?', @p82='?' (Size = 100), @p83='?', @p84='?', @p85='?', @p86='?', @p87='?' (Size = 4000), @p88='?', @p89='?' (Size = 100), @p90='?', @p91='?', @p92='?', @p93='?', @p94='?' (Size = 4000), @p95='?', @p96='?' (Size = 100), @p97='?', @p98='?', @p99='?', @p100='?', @p101='?' (Size = 4000), @p102='?', @p103='?' (Size = 100), @p104='?', @p105='?', @p106='?', @p107='?', @p108='?' (Size = 4000), @p109='?', @p110='?' (Size = 100), @p111='?', @p112='?', @p113='?', @p114='?', @p115='?' (Size = 4000), @p116='?', @p117='?' (Size = 100), @p118='?', @p119='?', @p120='?', @p121='?', @p122='?' (Size = 4000), @p123='?', @p124='?' (Size = 100), @p125='?', @p126='?', @p127='?', @p128='?', @p129='?' (Size = 4000), @p130='?', @p131='?' (Size = 100), @p132='?', @p133='?', @p134='?', @p135='?', @p136='?' (Size = 4000), @p137='?', @p138='?' (Size = 100), @p139='?', @p140='?', @p141='?', @p142='?', @p143='?' (Size = 4000), @p144='?', @p145='?' (Size = 100), @p146='?', @p147='?', @p148='?', @p149='?', @p150='?' (Size = 4000), @p151='?', @p152='?' (Size = 100), @p153='?', @p154='?', @p155='?', @p156='?', @p157='?' (Size = 4000), @p158='?', @p159='?' (Size = 100), @p160='?', @p161='?', @p162='?', @p163='?', @p164='?' (Size = 4000), @p165='?', @p166='?' (Size = 100), @p167='?', @p168='?', @p169='?', @p170='?', @p171='?' (Size = 4000), @p172='?', @p173='?' (Size = 100), @p174='?', @p175='?', @p176='?', @p177='?', @p178='?' (Size = 4000), @p179='?', @p180='?' (Size = 100), @p181='?', @p182='?', @p183='?', @p184='?', @p185='?' (Size = 4000), @p186='?', @p187='?' (Size = 100), @p188='?', @p189='?', @p190='?', @p191='?', @p192='?' (Size = 4000), @p193='?', @p194='?' (Size = 100), @p195='?', @p196='?', @p197='?', @p198='?', @p199='?' (Size = 4000), @p200='?', @p201='?' (Size = 100), @p202='?', @p203='?', @p204='?', @p205='?', @p206='?' (Size = 4000), @p207='?', @p208='?' (Size = 100), @p209='?', @p210='?', @p211='?', @p212='?', @p213='?' (Size = 4000), @p214='?', @p215='?' (Size = 100), @p216='?', @p217='?', @p218='?', @p219='?', @p220='?' (Size = 4000), @p221='?', @p222='?' (Size = 100), @p223='?', @p224='?', @p225='?', @p226='?', @p227='?' (Size = 4000), @p228='?', @p229='?' (Size = 100), @p230='?'], CommandType='Text', CommandTimeout='30']
       SET NOCOUNT ON;
       DECLARE @inserted0 TABLE ([ExpenseTypeId] int, [_Position] [int]);
       MERGE [ExpenseType] USING (
       VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, 0),
       (@p7, @p8, @p9, @p10, @p11, @p12, @p13, 1),
       (@p14, @p15, @p16, @p17, @p18, @p19, @p20, 2),
       (@p21, @p22, @p23, @p24, @p25, @p26, @p27, 3),
       (@p28, @p29, @p30, @p31, @p32, @p33, @p34, 4),
       (@p35, @p36, @p37, @p38, @p39, @p40, @p41, 5),
       (@p42, @p43, @p44, @p45, @p46, @p47, @p48, 6),
       (@p49, @p50, @p51, @p52, @p53, @p54, @p55, 7),
       (@p56, @p57, @p58, @p59, @p60, @p61, @p62, 8),
       (@p63, @p64, @p65, @p66, @p67, @p68, @p69, 9),
       (@p70, @p71, @p72, @p73, @p74, @p75, @p76, 10),
       (@p77, @p78, @p79, @p80, @p81, @p82, @p83, 11),
       (@p84, @p85, @p86, @p87, @p88, @p89, @p90, 12),
       (@p91, @p92, @p93, @p94, @p95, @p96, @p97, 13),
       (@p98, @p99, @p100, @p101, @p102, @p103, @p104, 14),
       (@p105, @p106, @p107, @p108, @p109, @p110, @p111, 15),
       (@p112, @p113, @p114, @p115, @p116, @p117, @p118, 16),
       (@p119, @p120, @p121, @p122, @p123, @p124, @p125, 17),
       (@p126, @p127, @p128, @p129, @p130, @p131, @p132, 18),
       (@p133, @p134, @p135, @p136, @p137, @p138, @p139, 19),
       (@p140, @p141, @p142, @p143, @p144, @p145, @p146, 20),
       (@p147, @p148, @p149, @p150, @p151, @p152, @p153, 21),
       (@p154, @p155, @p156, @p157, @p158, @p159, @p160, 22),
       (@p161, @p162, @p163, @p164, @p165, @p166, @p167, 23),
       (@p168, @p169, @p170, @p171, @p172, @p173, @p174, 24),
       (@p175, @p176, @p177, @p178, @p179, @p180, @p181, 25),
       (@p182, @p183, @p184, @p185, @p186, @p187, @p188, 26),
       (@p189, @p190, @p191, @p192, @p193, @p194, @p195, 27),
       (@p196, @p197, @p198, @p199, @p200, @p201, @p202, 28),
       (@p203, @p204, @p205, @p206, @p207, @p208, @p209, 29),
       (@p210, @p211, @p212, @p213, @p214, @p215, @p216, 30),
       (@p217, @p218, @p219, @p220, @p221, @p222, @p223, 31),
       (@p224, @p225, @p226, @p227, @p228, @p229, @p230, 32)) AS i ([DateTimeCreated], [DateTimeDeleted], [DateTimeUpdated], [Description], [ExpenseCategoryId], [ExpenseTypeName], [IsDeleted], _Position) ON 1=0
       WHEN NOT MATCHED THEN
       INSERT ([DateTimeCreated], [DateTimeDeleted], [DateTimeUpdated], [Description], [ExpenseCategoryId], [ExpenseTypeName], [IsDeleted])
       VALUES (i.[DateTimeCreated], i.[DateTimeDeleted], i.[DateTimeUpdated], i.[Description], i.[ExpenseCategoryId], i.[ExpenseTypeName], i.[IsDeleted])
       OUTPUT INSERTED.[ExpenseTypeId], i._Position
       INTO @inserted0;

       SELECT [t].[ExpenseTypeId] FROM [ExpenseType] t
       INNER JOIN @inserted0 i ON ([t].[ExpenseTypeId] = [i].[ExpenseTypeId])
       ORDER BY [i].[_Position];
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (13ms) [Parameters=[@__roleName_0='?' (Size = 256)], CommandType='Text', CommandTimeout='30']
       SELECT CASE
           WHEN EXISTS (
               SELECT 1
               FROM [AspNetRoles] AS [r]
               WHERE [r].[Name] = @__roleName_0)
           THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
       END
 info: Microsoft.EntityFrameworkCore.Database.Command[200101]
       Executed DbCommand (14ms) [Parameters=[@p0='?' (Size = 450), @p1='?' (Size = 4000), @p2='?' (Size = 256), @p3='?' (Size = 256)], CommandType='Text', CommandTimeout='30']
       SET NOCOUNT ON;
       INSERT INTO [AspNetRoles] ([Id], [ConcurrencyStamp], [Name], [NormalizedName])
       VALUES (@p0, @p1, @p2, @p3);
 info: Microsoft.AspNetCore.NodeServices[0]
       webpack built a83b2e5ee9bef8e0f926 in 14038ms
 Hosting environment: Development
 Content root path: C:\Users\wychan\Documents\Visual Studio 2017\Projects\Inteksoft.Claim.MVCEFAngular\Inteksoft.Claim.MVCEFAngular
 Now listening on: http://localhost:15444
 Application started. Press Ctrl+C to shut down.
 fail: Microsoft.AspNetCore.NodeServices[0]
       Hash: a83b2e5ee9bef8e0f926
       Version: webpack 2.6.1
       Time: 14038ms
                    Asset     Size  Chunks                    Chunk Names
           main-client.js  3.18 MB       0  [emitted]  [big]  main-client
       main-client.js.map  3.83 MB       0  [emitted]         main-client
       chunk    {0} main-client.js, main-client.js.map (main-client) 3.03 MB [entry] [rendered]
           [0] ./~/@angular/core/@angular/core.es5.js 489 kB {0} [built]
           [8] external "vendor_4d32c25f64f0bbc4b253" 42 bytes {0} [not cacheable]
          [53] ./ClientApp/boot.browser.ts 1.28 kB {0} [built]
          [54] (webpack)-hot-middleware/client.js?path=__webpack_hmr&dynamicPublicPath=true 6.68 kB {0} [built]
          [55] delegated ./node_modules/event-source-polyfill/eventsource.js from dll-reference vendor_4d32c25f64f0bbc4b253 42 bytes {0} [not cacheable] [built]
          [59] ./~/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js 5.88 kB {0} [built]
          [64] ./ClientApp/app/app.module.browser.ts 1.47 kB {0} [built]
          [86] ./~/querystring-es3/index.js 127 bytes {0} [built]
          [87] ./~/reflect-metadata/Reflect.js 48 kB {0} [built]
         [116] ./~/strip-ansi/index.js 161 bytes {0} [built]
         [118] (webpack)-hot-middleware/client-overlay.js 1.82 kB {0} [built]
         [119] (webpack)-hot-middleware/process-update.js 3.88 kB {0} [built]
         [120] (webpack)/buildin/module.js 517 bytes {0} [built]
         [121] ./~/zone.js/dist/zone.js 96 kB {0} [built]
         [125] multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts 52 bytes {0} [built]+ 111 hidden modules

       WARNING in ./~/@angular/core/@angular/core.es5.js
       5704:15-36 Critical dependency: the request of a dependency is an expression

       WARNING in ./~/@angular/core/@angular/core.es5.js
       5720:15-102 Critical dependency: the request of a dependency is an expression
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
       Request starting HTTP/1.1 GET http://localhost:53183/
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
       Request starting HTTP/1.1 GET http://localhost:53183/dist/__webpack_hmr
 info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
       Executing action method Inteksoft_Claim_MVCEFAngular.Controllers.HomeController.Index (Inteksoft.Claim.MVCEFAngular) with arguments ((null)) - ModelState is Valid
 info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
       Executing ViewResult, running view at path /Views/Home/Index.cshtml.
 info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
       Executed action Inteksoft_Claim_MVCEFAngular.Controllers.HomeController.Index (Inteksoft.Claim.MVCEFAngular) in 5601.2757ms
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
       Request finished in 5772.8703ms 200 text/html; charset=utf-8
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
       Request starting HTTP/1.1 GET http://localhost:53183/dist/main-client.js?v=JLCFvC4jMiuvNhpwIljqQrEAKLvZHz2dpiYjPFcrDcQ
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
       Request finished in 173.3628ms 200 application/javascript; charset=UTF-8
 info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
       Request starting HTTP/1.1 GET http://localhost:53183/dist/__webpack_hmr

I also try and catch the roleStore code, no exception throw out. 

I want insert the role records in one shot, how can I fix this issue?

Thank you for the reply. 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>