Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract entity property-column mapping in EF
    primarykey
    data
    text
    <p>I've been searching for ages for an answer to this. Although I've seen lots of similar posts, they all seem to be answered with "You need to read the mapping data directly form the XML", but I can't see an example of how to do it.</p> <p>I'm using EF 4.1, Database first and Dbcontext. I'm trying to implement an auditing process, which is done by overriding SaveChanges in my custom context. I query the state manager to pull back modified records etc. All standard stuff and lots of good examples out there.</p> <p>However, I want to write to a single audit table in the database, which has the column name being changed and the table name that the column belongs to. Currently I'm just writing out the entity property name for the column record and the entity type to the table record. OK this works, but it's not strictly correct as I should be writing the mapped column/table name NOT the conceptual representation. So far all my entites use exact mapping, i.e. they are the same names as the database names. However, if a developer one day creates an entity from a new table and specifies a different name for the mapping, my auditing won't be correct. I'll have audit details of a column name for example that doesn't exist! Also, I know you can map an entity to more than one table. So this is what I want to do ideally:</p> <p>At the the entity property level I want to find out the column name from the database and the table name it belongs to (including the full schema - i.e. for a table MySchema.MyTable I want to write to the audit table MySchema.MyTable NOT just MyTable). This process would safeguard the auditing process form developers editing mapping names, or creating entities from more than one table etc.</p> <p>All the examples say you need to use the CSSpace dataset as this holds the relationship info from the data store (SSpace) to the Conceptual store (CSpace). But this is used internally and cannot be access through the metadataworkspace API, apparently. Instead am I supposed to read the XML for CSSpace directly? If so, where is this file (embedded in to the assembly?) and how can I read it? I would think that what I want to do is very basic and an obvious requirement, yet it seems sooooo difficult to do.</p> <p>Any help greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload