Database First or Model First is not supported DbModelBuilder or EDMX from a DbContext .the error raises on line context.Business_Type.ToList(); RRS feed

  • Question

  • I use Model first(sql server) for my MVC project. If I want to push F5 without any break point it raises an error for for first calling method to query the database base on context.

    The error is:

    "Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel." I use EF.4 and I update my model through diagram.

    *But if I use F10/F11 it passes that line successfully and for the rest methods which query on context it works fine with F5.

    The problem is only with the first calling method.

        BApp_Entities context;

            public RepositoryBusinessType()
                context = new BApp_Entities();

            public IList<Models.Business_Type> GetAll()
                return context.Business_Type.ToList();

    context is a instance of my model,then I need to make a query to retrieve my data,like:context.Business_Type.ToList();

    the error raises on line context.Business_Type.ToList();

    Monday, January 21, 2019 9:51 PM

All replies

  • Hi David Rikardson,

    Please open your model (Edmx file) right click empty place -> Update Model from database -> choose the modified table to update them in model. 

    If the issue still exists, could you please share a simple sample to reproduce the issue via OneDrive.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 22, 2019 2:02 AM