Added column to database, now I need to update my view

Hello,
I have almost finised a complex application. Now unfortunately I need to ad a column to a table and show it in a complex form I cannot rebuild from scratch.
Please tell me the steps I need to do to reach this goal because I am trying to infer data again but I destroy existing code.
Thanks,
Mario

Not sure how infer will destroy your code. The infer will retrieve the latest schema and the code generation will generate the updated code - if you need to display and modify the new field you should modify your CRUD pages manually.

Hi I am trying to modify crud, models and backend but I still fail when I click save button.
Have you a list of files or directories to check? It is an angular project with c# backend.

All files will be generated automatically unless they are in your application ignore list.

I explain better: I proceed with modifying all crud components by hand (c# files, typescript files, json files and so on) to add the new field.
Now I suppose to have modified all I need. I launch the software I can see the new field but when I save, I get an exception. So probably I have forgot to modify some files.
Can you tell me the list of c#/json/typescript files to modify to manually add a new field?
Thanks,
Mario

Not sure why you need to do this. You’ve put all files in your application in ignore list? When you infer the data source Radzen will update the meta. When you run Radzen will generate relevant code for both client and server applications. The files that needs to be updated depends on what exactly you want to do and what kind of field is added in the database. If the field for example is part of foreign key or primary key almost everything should be regenerated. Models, services, context, controllers and pages.

I still not understand: you told me " if you need to display and modify the new field you should modify your CRUD pages manually." I am doing it. But when I run the software, I open a crud and I save using the crud I get an exception.

By using Radzen, not directly in the generated code since it will be overwritten unless put in ignore list.

Assuming you have not modified any of the Radzen auto generated files this is how I do it

  1. add the new column to the database
  2. In Radzen >Data >infer schema
  3. open the existing page in Radzen page designer and add the new bound column
  4. Run the application. This will regenerate controllers, model classes, client files etc.

I have done as you suggested and now the application does not load data in edit page. I am quite annoyed because the project is almost finished the customer asked me to add a field and I cannot spend two days to add a simple field. I can give you access to git repository but the time I saved initially using radzen it is gone in a very long list of problems that I can solve only asking you.

Have you checked the logs for a likely reason?
Check both the server log and the javascript console.
Does the Edit page display correctly in the Radzen form designer?
if not compare the meta\pages\xxx.json with version that worked. It likely has a syntax error.
If form displays correctly check the parameters being passed to edit form at runtime.

Did you debug your application to see what the error is? You can always revert the previous version of the application from git. You can also compare what the changes in the generated code are.

We are sorry to hear that. To help you further we would need additional information - for example what the error messages/exceptions are. Alternatively as a compensation we can issue a refund for your Radzen subscription and cancel it.

Obviously I use git to use git stash, actually I am doing it several times in an hour.
Debugging shows no errors but now I have discovered that in new version of generated edit-ricoco-generated.components.ts is missing this piece of code:

if (this.fill==true) {
this.ricocoDb.getRicocoByid(null, this.parameters.id)
.subscribe((result: any) => {
this.ricoco = result;

  Promise.resolve().then(() => {
    this.ricoco.utente=this.security.user.name
  }).then((result: any) => {
    Promise.resolve().then(() => {
      (this as any).aggiornaPassFail(this.ricoco.idStandardColore)
    }).then((result: any) => {
      (this as any).aggiornaPassFailFinito(this.ricoco.idStandardColoreFinito)
    }, (result: any) => {

    });
  }, (result: any) => {

  });
  }, (result: any) => {
      this.canEdit = !(result.status == 400);
  });
}

That is the code that loads the main data to edit....

That code looks as custom. The same as (this as any).aggiornaPassFail(this.ricoco.idStandardColore) and the other code. This whole thread is trying to explain that - if you have made changes to the automatically generated page you will lose them if you regenerate the page. This is why you have to add the new field manually. It is as simple as adding a new item in the Fields collection of the form in the property grid and setting the right property type and name.

Ok this is what I have done:

  1. generated all CRUDs using infer database
  2. modified cruds only using RADZEN
  3. added some custom javascript code in edit-ricoco.components.ts following your guidelines (I have asked you in the forum)
  4. added some custom c# code in RicocosControllerCustom.cs again following your guidelines

I do not know what you do with "made changes to automatically generated page" because I accurately avoided it.
Anyway I have tried to do this: It is as simple as adding a new item in the Fields collection of the form in the property grid and setting the right property type and name.
But if I do it or if I do not do it the edit page is not filled with data. On radzen gui log I can see clearly that the select query for ricoco is not done at all.

This is still modifying the generated page. And those changes will be lost if you regenerate those pages from the infer data source dialog.

If it lacks the getRicocoByid invoke data source method it won't load any data. Check the Load event of that page - it should contain such code as the first action. You can also attach a screenshot of both the Load event of the Edit page and the Fields configuration of the Form component. Also paste the code of the updated C# class that represents the database table which this edit page is supposed to edit.

Even if I do not check "generate crud pages" as you shown in the screenshot?

If you don't check generate crud pages then the page code should not be modified in any way. The only thing that can remove the code for fetching the item is a change to the Load event. How does the Load event of that page look like? What actions are specified?

Providing some screenshots and the code of your model class will greatly improve our chance of helping you.

Here are the screenshots of the load event before adding the field


c# model before adding field

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace RicocoNg.Models.RicocoDb
{
  [Table("ricoco")]
  public partial class Ricoco
  {
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int id
    {
      get;
      set;
    }
    public int? idStandardColoreFinito
    {
      get;
      set;
    }

    public StandardColore StandardColore { get; set; }
    public int? idScalaProduzione
    {
      get;
      set;
    }

    public Scala Scala { get; set; }
    public int idReparto
    {
      get;
      set;
    }

    public Reparto Reparto { get; set; }
    public int? additivo1
    {
      get;
      set;
    }

    public Additivi Additivi { get; set; }
    public int? additivo2
    {
      get;
      set;
    }

    public Additivi Additivi1 { get; set; }
    public int? additivo3
    {
      get;
      set;
    }

    public Additivi Additivi2 { get; set; }
    public int? additivo4
    {
      get;
      set;
    }

    public Additivi Additivi3 { get; set; }
    public int? additivo5
    {
      get;
      set;
    }

    public Additivi Additivi4 { get; set; }
    public int idUtente
    {
      get;
      set;
    }

    public Utenti Utenti { get; set; }
    public int idStandardColore
    {
      get;
      set;
    }

    public StandardColore StandardColore1 { get; set; }
    public int idStruttControllo
    {
      get;
      set;
    }

    public Controllo Controllo { get; set; }
    public int idScalaMescole
    {
      get;
      set;
    }

    public Scala Scala1 { get; set; }
    public int idCartaRiferimento
    {
      get;
      set;
    }

    public Cartum Cartum { get; set; }
    public int? pigmento1
    {
      get;
      set;
    }

    public Pigmenti Pigmenti { get; set; }
    public int? pigmento2
    {
      get;
      set;
    }

    public Pigmenti Pigmenti1 { get; set; }
    public int? pigmento3
    {
      get;
      set;
    }

    public Pigmenti Pigmenti2 { get; set; }
    public int? pigmento4
    {
      get;
      set;
    }

    public Pigmenti Pigmenti3 { get; set; }
    public int? pigmento5
    {
      get;
      set;
    }

    public Pigmenti Pigmenti4 { get; set; }
    public int idCartaProduzione
    {
      get;
      set;
    }

    public Cartum Cartum1 { get; set; }
    public string capoProgetto
    {
      get;
      set;
    }
    public string codiceColore
    {
      get;
      set;
    }
    public string codiceMateriale
    {
      get;
      set;
    }
    public DateTime dataImmissione
    {
      get;
      set;
    }
    public decimal? finDL
    {
      get;
      set;
    }
    public decimal? finDa
    {
      get;
      set;
    }
    public decimal? finDb
    {
      get;
      set;
    }
    public decimal? finTollDL
    {
      get;
      set;
    }
    public decimal? finTollDa
    {
      get;
      set;
    }
    public decimal? finTollDb
    {
      get;
      set;
    }
    public string linkExcel
    {
      get;
      set;
    }
    public string masContrMescole
    {
      get;
      set;
    }
    public decimal? mesDL
    {
      get;
      set;
    }
    public decimal? mesDa
    {
      get;
      set;
    }
    public decimal? mesDb
    {
      get;
      set;
    }
    public decimal? mesTollDL
    {
      get;
      set;
    }
    public decimal? mesTollDa
    {
      get;
      set;
    }
    public decimal? mesTollDb
    {
      get;
      set;
    }
    public string nomeColore
    {
      get;
      set;
    }
    public string nomeMasterArticoloFinito
    {
      get;
      set;
    }
    public string nomeProgetto
    {
      get;
      set;
    }
    public string note
    {
      get;
      set;
    }
    public string noteFinito
    {
      get;
      set;
    }
    public string noteMescole
    {
      get;
      set;
    }
    public string noteProduzione
    {
      get;
      set;
    }
    public string numProgetto
    {
      get;
      set;
    }
    public string numeroMasterArticoloFinito
    {
      get;
      set;
    }
    public decimal pesoEsp
    {
      get;
      set;
    }
    public decimal pesoSkin
    {
      get;
      set;
    }
    public decimal? prodDL
    {
      get;
      set;
    }
    public decimal? prodDa
    {
      get;
      set;
    }
    public decimal? prodDb
    {
      get;
      set;
    }
    public decimal? prodTollDL
    {
      get;
      set;
    }
    public decimal? prodTollDa
    {
      get;
      set;
    }
    public decimal? prodTollDb
    {
      get;
      set;
    }
    public decimal? valAdditivo1
    {
      get;
      set;
    }
    public decimal? valAdditivo2
    {
      get;
      set;
    }
    public decimal? valAdditivo3
    {
      get;
      set;
    }
    public decimal? valAdditivo4
    {
      get;
      set;
    }
    public decimal? valAdditivo5
    {
      get;
      set;
    }
    public decimal? valPigmento1
    {
      get;
      set;
    }
    public decimal? valPigmento2
    {
      get;
      set;
    }
    public decimal? valPigmento3
    {
      get;
      set;
    }
    public decimal? valPigmento4
    {
      get;
      set;
    }
    public decimal? valPigmento5
    {
      get;
      set;
    }
    public string masContrFinito
    {
      get;
      set;
    }
    public decimal? zehMin
    {
      get;
      set;
    }
    public decimal? zehMax
    {
      get;
      set;
    }
    public decimal? mtgMin
    {
      get;
      set;
    }
    public decimal? mtgMax
    {
      get;
      set;
    }
  }
}