none
Ignore Custom Tables in Entity Framework

    Question

  • I have a database that I'd like to contain two sets of tables and logic:

    1. Basic tables to support CRUD operations in my application that are developed and accessed via EF

    2. Advanced tables, stored procedures, and views that are managed and accessed separately (not via entity framework)

    In my testing, it appears that EF 5.0 ignores tables that are not related to entities defined in EF. However, I'm trying to ensure that will remain the case and that there won't be any surprises.

    Thanks,

    Eric


    Friday, June 28, 2013 7:26 PM

Answers

  • Hi Eric;

    The only tables that can be accessed through Entity Framework are those tables that are in the EF model. So do not include any of the tables that are associated with items 2 above and those tables can not be accessed with EF. 

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Friday, June 28, 2013 8:14 PM

All replies

  • Hi Eric;

    The only tables that can be accessed through Entity Framework are those tables that are in the EF model. So do not include any of the tables that are associated with items 2 above and those tables can not be accessed with EF. 

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Friday, June 28, 2013 8:14 PM
  • Thanks Fernando. Just to be sure, does this mean that if I specify MigrateDatabaseToLatestVersion, it will not remove/alter the unreferenced tables, and will simply ignore them?

    Ex. Database.SetInitializer(newMigrateDatabaseToLatestVersion<WorkflowDBContext, Configuration>());

    Thanks,

    Eric

    Monday, July 01, 2013 3:53 PM
  • Hi Eric;

    Not sure about your last question. If you were using EF Database First approach with the EF Designer then what I stated would hold. But using Entity Framework and Migration this may not hold true seeming that the database will be re-created. 

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, July 01, 2013 9:09 PM