Migrating an Entity Framework 6 context from EDMX to Code-first

Viewed 264

I have a complex ("enterprise") database that has hundreds of tables, and a single EDMX model containing all the relevant tables, views stored procedures, etc.

I have hit the limit of what the EDMX tool is capable of doing. When I "Update Model From Database", it fails:

The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.

Using SQL profiler, I can see a query running sp_executesql and passing all the EDMX objects as parameters, and there are more than 2100 parameters. Each entity has the database name, schema name and table name, and occurs twice in the list. Thus, working backwards, I can see that having > 350 tables with complex relationships is now preventing the EDMX from updating.

I cannot break down the edmx into smaller contexts, as it would require substantial re-development of the application, which is not in scope.

I can see that all of the entities have POCOs generated, but that the relationships and other model building information is stored in the EDMX and evaluated at run time.

I cannot be sure that the model is purely "created from the database", or if previous developers have manually added to it (e.g. adding a relationship between two tables that may not have had a foreign key relationship).

My question is, are there any tools that will extract model building information from an EDMX into code-first style model builders (such that I could use the existing EDMX generated POCOs), or "reverse engineer" an entire existing EDMX context to code-first?

Alternatively, is there anything I can do to configure the EDMX designer to be "smarter" about how it parametrizes it's own queries. Having @p1=N'dbo'...@p4=N'dbo'...@p7=N'dbo'......@2097=N'dbo'...` does not seem like the most efficient use of the 2100 parameter limits. Can I configure it to, say, identify that all values are the same and re-use @p1?

Thanks.

0 Answers
Related