Error while deploying the code on azure.

harkanwar1313 1 Reputation point
2022-12-21T03:19:27.013+00:00

I am getting the below error:

The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715

I tried to update config file.
But still the same error. Even the project is database first. but still having the same error

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,326 Reputation points Microsoft Employee Moderator
    2022-12-21T06:41:58.263+00:00

    @harkanwar1313 , I don't know what your config file looks like, but the conflict isn't with your *.config (app if it's console app or web if it's a web app) referencing your .edmx file but that your DbContext is attempting to initialize a model using POCO classes. Check your DbContext.context.tt file. The .tt file is text transform file that generates the classes EF uses for your model. It's been a while since I've used it but somewhere in that file will determine how DbSet<T> or EntitySet<T> is getting generated inside the context.

    However, the latest versions of Ef Core doesn't support edmx files. To address this issue, what I would suggest is migrating your edmx file to scaffolding a new DbContext into a code-first approach.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.