1

I am building a Web Application where i am creating a dynamic form where user can create different field to make his or her own form.Then i want the application build their model dynamically based on the form fields.At the end database table will be created from that generated model and field value will be inserted as table data.Any suggestion or solution is highly appreciated.

1 Answer 1

1

I personally would shy away from trying to create the database table dynamically, but take an approach where you store the fields in a table, and relate them to a form object. Something like this:

public Form
{
    [Key]
    public int FormId {get;set;}
    public string Name {get;set;}
    public IList<Field> {get;set;}
}

public Field
{
    [Key]
    public int FieldId {get;set;}
    public string FieldName {get;set;}
    public string FieldValue {get;set;}

    [ForeignKey("FormId")]
    public Form Form {get;set;}
    public int FormId {get;set;}
}

With this structure, creating a form would simply be a case of creating a Form object, and then you can just simply add as many Field objects to it as you wish. Each Field object can be named anything that you want, and would be unique to the Form it is associated to

Sign up to request clarification or add additional context in comments.

1 Comment

How will we store form data? and form template?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.