Entries:
Comments:
Discussions:

Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Shadow Properties in Entity Framework 7

7 minutes, 0 seconds

Download

Right click “Save as…”

In this short video Rowan describes shadow properties new in Entity Framework 7. This is a super useful feature for those times when your database and your class model don't quite match up. Would love your thoughts!

Here are some links for more information:

As an aside, I spent a couple of days with Rowan (and team) recording additional videos regarding Entity Framework 7 and some of the new features to look for in the coming release. Stay tuned!

Tag:

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing
  • Wow, this is exactly what I need. My scenario is following: in my domain model a have geo coordinates, which are represented by my domain type (because I don't want to have dependency on the DbGeography EF's type). But my repository implementation has need to query the data using geographical filter like distance, so it has to use DbGeography . To solve this problem, I had to create a "shadow" model which was linked to the main model and both were mapped into the same table. When a model instance is being added to the context, I create a shadow model instance, and convert my geography property to DbGeography property in the shadow model, and save them both. I can query the context for main model, but filter by the shadow model. All this machinery (including the shadow model) is hidden in the repository implementation, so the client code doesn't know about it.

    So having shadow properties will simplify my approach valuably, reducing amount of configuration code and removing possible limitations.

    Of course, the ideal solution of my problem would be type conversion support, however, not sure how would model query part work - LINQ statements are written against model, not against (imaginary) converted model.

  • I'm wondering, can this feature be used to move "row version" property out of a domain model?

  • , andriysavin wrote

    I'm wondering, can this feature be used to move "row version" property out of a domain model?

    Yes, that would be a perfect scenario for this feature.

  • afshinsafshins

    This was very useful. I just need to know how I can use the value of a shadow property to set another property. This is my scenario: My entity has a List property which I want to store in database in a serialized form (json). I can use a string shadow property to serialize the List property; however, I just don't know how to deserialize it back to the list property.

  • CorneliuCorneliu

    Ron, Is it possible to use shadow properties to build relations between tables/entities that don't exist in the original model? Like a new one-to-one relation?
    E.g. Blog/BlogDetails?
    I'd like to be able to do:
    OnModelCreating()
    {
    modelBuilder.Entity<Blog>(entity=>{
    entity.Property<BlogDetails>().Metadata.IsShadownProperty = true;
    });
    }
    var q = from b in db.Blogs select b;
    q.Include("BlogDetails") ? or something those lines.
    Thanks.

Remove this comment

Remove this thread

Close

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.