I'm using EntityFramework - Code First, DBContext with POCO classes.
At runtime, how can i detect properties belongs to fields that generated in the database, marked as .HasDatabaseGeneratedOption , .IsRowVersion (readonly?) etc.
I looked at var xxx = Entity.GetType().GetProperty("ID").Get
... , no luck.
public partial class OnMuhasebeContext : DbContext
{
public bool IsDatabaseGeneratedProperty <?>(...)
{
// Parameters :
// We know all poco classes of course
// also parameters can be instance type
}
}
Update:
please read "database generated" as "field whose value generated by database" and marked in the model to reflect that.
These properties are both belongs to database generated fields and marked as identity and RowVersion using Fluent API.
public class POCOMap : EntityTypeConfiguration<POCO>
{
public POCOMap()
{
// Primary Key
this.HasKey(t => t.ID);
this.Property(t => t.RowVersion)
.IsFixedLength()
.HasMaxLength(8)
.IsRowVersion();
}
}
Important point: How to get properties are marked in the model or code first model, using Fluent API or Data Annotions. Databases itself not important, like the philosophy behind the Entity Framework.