Search code examples
c#entity-frameworkado.netentity-framework-6ado.net-entity-data-model

Ado.net data entity model EF 6.x taking freezing on Wizard


I have been using ADO.NET Entity Data Model Ef 6.x database first with different MS SQL Server databases and it has been working alright until I've got a prod local copy of production database schema having a lot of tables. I'm not doing anything fancy rather just trying to add DbContext with the standard wizard. For some reasons, it is taking ages and never successfully creates DbContext and entity models. It takes insane amount of time even when I try to select one single table out of whole lot of tables but it at least successfully creates DbContext. I need to create DbContext for pretty much every table within the database. Any thoughts how can I generate that using ADO.NET entity data model EF 6.x?


Solution

  • Following SQL script resolved my problem.

    ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=ON
    

    Once you generate DbContext running the above script you should turn that back off with the following script

    ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=OFF