Entity Framework - getting a table's column names as a string array
How about:
var names = typeof(User).GetProperties()
.Select(property => property.Name)
.ToArray();
Of course, this can be used for any type, not just an EF table.
var res = typeof(TableName).GetProperties()
.Select(property => property.Name)
.ToArray();
OR
var res = dbContext.Model.FindEntityType(typeof(TableName))
.GetProperties().Select(x => x.Relational().ColumnName)
.ToList();
var index = 0;
var propertyInfo = res[index].PropertyInfo;
var columnName = res[index].Relational().ColumnName;
var propertyName = propertyInfo.Name;
var propertyValue = propertyInfo.GetValue(sourceObject); // NEED OBJECT TO GET VALUE