Using web assembly .net 5 with sql table using Identity(1,1) on Id fails on insert

here is the sql table script...

I can insert rows into my table outside of my app.
I can remove rows using my app.
I can edit rows in my app.
I cannot insert new rows in my app.

I used the wizard to create new blazor web assembly and added datasource with crud.
All works except for insert.
are you are using odata, versus efcore?

Is an identity Id field not allowed?

here is example of error...

Our Sample database is using exactly the same definitions for primary keys and all operations are working normally on my end:

Insert:



Update:



Delete:



Of course we are using OData + EF for WASM - there is no direct database access like in server Blazor.

Here is an example application:
https://drive.google.com/file/d/19BJ1LwHIhaqlwIjy_avOpE_8tN-lV8y3/view?usp=sharing

I don't know when you created your sample application, but what I'm telling you is that if i use the sql table i sent you and use your wizard, this is the result.

So using your "sample app" as proof, is not proof.
There could be a problem that was introduced into your "wizard" that is creating this issue.

Have you tested it on windows 10, iis 10 and .net 5 blazor web assembly using wizard with the table i sent?

If you have not, then i cannot accept that this is my problem, and not a problem with radzen wizard for sql tables.

Thanks for your time.

We can't test anything from a screenshot. Please paste the SQL script here as we won't do manual OCR as it is prone to errors.

Also you can attach a debugger to see what the exception is. We attached a working application to prove there is no known issue with Identity columns.

sql version: Microsoft SQL Server 2019 (RTM-CU8) (KB4577194) - 15.0.4073.23 (X64) Sep 23 2020 16:03:08 Copyright (C) 2019 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

the table:

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[User](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar] (50) NOT NULL,
[Dept] [nvarchar] (50) NOT NULL,
[CreatedDate] [datetime] NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

i will see about getting the exception, i have tried, but still elusive, i'm not an expert at troubleshoting web apps. any tips?

Run the application with Visual Studio. It should break on unhandled exceptions by default. Radzen also logs all server exceptions in its Output window.

what i noticed about this issue is that i do get a bunch of exceptions....
all the exception files below are empty.
and it does not crash, it just gives that message i showed in my first post.

Those are not exceptions - those are the IIS log files :slight_smile:

The message is most probably caused by a server-side exception.

So what happens when you run the application from Radzen instead of IIS?

the same happens inside the radzen app , with a dialog with "cannot add user"

i decided to try again, and this time just chose the make crud pages and all defaults after that.
i decided to make a slightly different new table
The good news is that it worked.

Being that i didn't check all the boxes maybe had an effect, in that by checking those boxes it changes the functionality of the edit forms i'm guessing? Thanks for your support.

exept i used blazor server this time..ooops...trying again with web assembly.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[UserInfo](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [char] (100) NOT NULL,
[Date] [datetime] NOT NULL,
CONSTRAINT [PK_UserInfo] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

okay so with the table above, i created blazor server app .net 5 and used all features on wizard for data and all features worked.

If i then create a new app as blazor web assembly, i still receive an error on insert of new rows.

The problem was caused by the datetime property, not by the key. I've fixed it and you can update your project to just published Radzen.Blazor 2.17.2.

1 Like

Much appreciated, Thanks for your support.

to resolve i went in and updated project nuget packages in vs...and then back to radzen and run, worked!

Keep the goodness coming!