none
Schema Validation in Entity Framework RRS feed

  • Question

  • My situation:

    In development I work against a db schema and create my data model from and test against that schema.

    In production I have to run my application against multiple databases that have schemas very similar to the schema I developed against, but may have some differences i.e. extra columns, missing columns etc. (I know this is not ideal, but it's the reality in which I'm operating.)

    Is there a mechanism/tool that I can run using my generated EDMX file, that I can point to a database and validate my generated data model against that particular database?

    Thanks,

    ArchieD

    Monday, February 18, 2013 10:31 PM

Answers

  • Hi,

    I don't know of any tools that will do what you are asking with an EDMX model. One of the SQL Comparison tools that exist would be able to tell you the differences between two databases though, there are several that you could probably use. That will give you the columns that are different and possibly even generate SQL to bring them all closer together if that's an option.

    As to determining if they are compatible with the model, you could possibly do what you are after with parts of the Code First Migrations pipeline, but you aren't using code first and I'm not sure what you need is public anyway. So I don't think what you after exists at the moment.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Wednesday, February 27, 2013 12:33 AM
    Moderator

All replies

  • Hi Archie,

    Welcome to the MSDN forum.

    I am not sure what means “validate my generated data model against that particular database”. Do you mean you want to use EDMX file to check if the target database is different?

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 20, 2013 8:26 AM
  • Hi Alex,

    Thanks for getting back to me.

    Maybe an example will help clarify what I'm looking for ...

    I have 2 databases, A and B.
    I generate a data model (my EDMX file) from Database A using the 'Update Model From Database' menu option in the Visual Studio Designer.

    My questions - Is there a tool that I can use to validate my data model generated above (my EDMX file) against database B to tell me that Database B is compatible with my data model, or if not, what the discrepancies are so I can go and address them?

    Thanks,

    ArchieD

    Wednesday, February 20, 2013 6:04 PM
  • Hi,

    I don't know of any tools that will do what you are asking with an EDMX model. One of the SQL Comparison tools that exist would be able to tell you the differences between two databases though, there are several that you could probably use. That will give you the columns that are different and possibly even generate SQL to bring them all closer together if that's an option.

    As to determining if they are compatible with the model, you could possibly do what you are after with parts of the Code First Migrations pipeline, but you aren't using code first and I'm not sure what you need is public anyway. So I don't think what you after exists at the moment.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Wednesday, February 27, 2013 12:33 AM
    Moderator