Trouble adding a new table to Radzen Blazor Studio

Existing Blazor WASM App, successfully builds in both Radzen Blazor Studio and Visual Studio Community 2022.

I'm trying to add a new database table, then add it to my application, but I get build errors after adding it.

I've created a table in SQL Server:

CREATE TABLE [dbo].[Test1Lead](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Date_Created] [date] NOT NULL,
	[Street] [varchar](50) NOT NULL,
	[City] [varchar](50) NOT NULL,
	[State] [varchar](2) NOT NULL,
	[Zip] [int] NOT NULL,
 CONSTRAINT [PK_TestLead1] 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

I then go to "Data" in studio:

  • Choose existing DB connection
  • Click Next
  • Uncheck "Overwrite existing files"
  • Expand Tables
  • Select my new table (leaving all existing tables checked)
  • Uncheck "Cascade delete
  • Check "Optimistic concurrency"
  • Click Next
  • Click "Generate pages for CRUD operations"
  • CRUD type pages selected
  • Click Next
  • Uncheck "Overwrite existing files"
  • Expand entities, ensure all are selected including new one
  • Check "Search as you type"
  • Check "Enable reload on optimistic concurrency error"
  • Click Finish

Result:

The build in Blazor Studio fails:

Building...
C:\Users\Don\code\wep.westelmcrm\Client\Pages\Test1Leads.razor.cs(56,62): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'GetTest1Leads' and no accessible extension method 'GetTest1Leads' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\Test1Leads.razor.cs(58,32): error CS0428: Cannot convert method group 'Count' to non-delegate type 'int'. Did you intend to invoke the method? [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\Test1Leads.razor.cs(84,72): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'DeleteTest1Lead' and no accessible extension method 'DeleteTest1Lead' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\AddTest1Lead.razor.cs(46,62): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'CreateTest1Lead' and no accessible extension method 'CreateTest1Lead' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\EditTest1Lead.razor.cs(40,57): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'GetTest1LeadById' and no accessible extension method 'GetTest1LeadById' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\EditTest1Lead.razor.cs(49,62): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'UpdateTest1Lead' and no accessible extension method 'UpdateTest1Lead' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]
C:\Users\Don\code\wep.westelmcrm\Client\Pages\EditTest1Lead.razor.cs(79,57): error CS1061: 'WestElmCRMTenantDBService' does not contain a definition for 'GetTest1LeadById' and no accessible extension method 'GetTest1LeadById' accepting a first argument of type 'WestElmCRMTenantDBService' could be found (are you missing a using directive or an assembly reference?) [C:\Users\Don\code\wep.westelmcrm\Client\WestElmCRM.Client.csproj]

The build failed. Fix the build errors and run again.

The build also fails in Visual Studio.

Doing a "git status" here are the changes:

./Client/Shared/MainLayout.razor:

  • the new table is added to the menu, but Razor also readds all the existing pages that I've manually removed.

./Server/Program.cs

  • one command is slightly reformatted, but no actual change to it
  • adds the entity set for new table:
oDataBuilderWestElmCRMTenantDB.EntitySet<WestElmCRM.Server.Models.WestElmCRMTenantDB.Test1Lead>("Test1Leads");

./Server/WestElmCRM.Server.csproj

  • updates the OpenXML version, no impact

Pages added:

  • Client/Pages/AddTest1Lead.razor
  • Client/Pages/AddTest1Lead.razor.cs
  • Client/Pages/EditTest1Lead.razor
  • Client/Pages/EditTest1Lead.razor.cs
  • Client/PagesTest1Leads.razor
  • Client/Pages/Test1Leads.razor.cs
  • Server/Controllers/WestElmCRMTenantDB/Test1LeadsController.cs
  • Server/Models/WestElmCRMTenantDB/Test1Lead.cs

Could someone help me understand why I'm unable to add a new table to my application?

It appears that Radzen Blazor Studio is not adding entries into the Services file.

Is there something I'm doing incorrectly here?

It seems I need to check the first "Overwrite existing files" toggle.

This might be clearer if it was specified which files are being overwritten.

None of the other entities' files have been overwritten.

I'm not sure I understand the use case to add the Model and CRUD pages but not add the new entity to Services.

Hi @DB1234,

Indeed in this case "Overwrite existing files" has to remain checked otherwise the service won't be updated with the new entity related methods. The same goes with the Entity Framework DB context.

In this particular scenario it doesn't make sense to uncheck it ever but this option is present in all template wizards and we keep it for consistency.

I've now tried to add a new column to this test table.

On the dialog for "Code generation settings", I select "Overwrite existing files" as I need to overwrite the existing entity to get the new column.

Under "Select which entities to scaffold" I select only the entity that changes.

Radzen then removes all the "builder.Servers.AddControllers().AddOdata references to all the entity sets from .\Server\Program.cs

What is the correct way to add a column without overwriting changes to all the other entities?

In thinking of ways to improve this database update process, the way SQL Server's installer handles changes comes to mind.

You go through the entire dialog, selecting all options, and then before any changes are made there is a final screen that gives a list of all the changes that will be made.

I think Radzen has been great so far to scaffold up the initial pages, but it's causing me to hesitate using it to extend/change the app as I move forward as I don't know what it will change.

If there are scenarios where unchecking an option never makes sense, it seems like it would be good to disable that option.

I'm not the most skilled with EntityFramework so maybe some of these questions/concerns aren't entirely due to Radzen.

If you uncheck the entities in the tree they will be removed. This tree represents the current state of the scaffolded entities.