I have a Entity Framework Database First Model.I want to write a MSTest/nUnit test to verify that all the stored procs, tables and views that are defined in my edmx model are still valid on the database.
How do I read the Entity Framework Model and validate it against a given connection?
database;unit testing;entity framework
I found the answer:var list = context.MetadataWorkspace.GetItems<EdmFunction>(DataSpace.SSpace).Where(i=>i.ReturnParameter == null);This returned the correct schema and stored procedure name. I then could call for each item in the list: var sqlCommands = string.Format(SELECT 'x' FROM sys.objects WHERE object_id = OBJECT_ID(N'{0}') AND type in (N'P', N'PC'), storedProcedureName);var exists = dbContext.Database.SqlQuery<string>(sqlCommands).Any();