Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
Hi

in have one table in my db, Table Name is Students

Column Name  DataType

ID                       int

FieldName        varchar(50)

and i insert some records in that table

below :

ID   FieldName

1    ID

2   FirstName

3  LastName

4 Standard

5 Section

6 School

7 City

I insert 7 records

My Model Class

public class Studentdetails
{
public int UID { set; get; }
[Required]
public string ID { set; get; }
[Required]
public string FirstName { set; get; }
[Required]

public string LastName { set; get; }
[Required]
public string Standard { set; get; }
[Required]
public string Section { set; get; }
[Required]
public string School { set; get; }
[Required]
public string City { set; get; }
}

My Requirement is When I add New New Record in Students table

that will added dynamically in to Studentdetails class as new property

Ex Suppose i add new record like phno then my table come like this

ID   FieldName

1    ID

2   FirstName

3  LastName

4 Standard

5 Section

6 School

7 City

8 Phno

i want my model automatically change in to below like this

public class Studentdetails
{
public int UID { set; get; }
[Required]
public string ID { set; get; }
[Required]
public string FirstName { set; get; }
[Required]

public string LastName { set; get; }
[Required]
public string Standard { set; get; }
[Required]
public string Section { set; get; }
[Required]
public string School { set; get; }
[Required]
public string City { set; get; }

public string Phno { set; get; }

}

anybody know pls answer this.........
Posted

1 solution

Not sure whether there is a way "automatic", But you can surely do it through Updating the Model from EDMX file.

Refer

database-first-development/changing-the-database[^]

changing-database-fields-and-updating-ado-entity-model-edmx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900