Last post Mar 08, 2018 02:49 AM by Brando ZWZ
Mar 05, 2018 08:21 PM|Yossu|LINK
I have an ASP.NET MVC5 web site that uses EF6. When I publish (to disk package) and then deploy the web site, I find that the next time I try to debug in VS2017, I get the above error. For some reason I never worked out, cleaning the solution and rebuilding
sorts it out.
Today, I published and deployed, and found that the production web site throws the same error. Having spent a long time searching, it seems that the most common cause of this error is a mistake in the connection string. However, I don't think that's the
problem in my case, as 1) the Web.config file hasn't changed for quite some time (I can see the last change in source control, and have published and deployed successfully several times since then) and b) if I copy the connection string from the published
Web.config file into the one in VS, then I can run it and it loads the data from the remote database.
Not sure it's relevant, but my PC crashed last week (wobbly memory card) and I had to reinstall Windows 10. This is the first time I've published and deployed since then. However, the file structure within the project hasn't changed, so I wouldn't expect
this to be an issue.
Anyone any idea how I find out what's gone wrong here?
Mar 05, 2018 08:49 PM|Yossu|LINK
OK, so I'm really confused now!
I cleaned the solution, closed VS, deleted the contents of the Publish folder, and deleted the bin and obj folders, then restarted Vs and published, and it all works fine!
If anyone has any explanation at all for this I would like to hear it!
Mar 06, 2018 05:28 AM|Brando ZWZ|LINK
According to the error message, it means the application is unable to load the EDMX.
There multiple reason will cause this:
You might have changed the MetadataArtifactProcessing property of the model to Copy to Output Directory.
The connection string is wrong.
The namespace is changed.
I guess you may include the bin and obj folder in the application project.
It may also cause the build error.
Mar 06, 2018 07:08 PM|Yossu|LINK
Hello, thanks for the reply.
As I explained in my first post, the problem goes away by cleaning the solution and deleting the two folders (found out after that there's no need to restart VS), so I don't see how it can be related to the model, connection string or namespace.
Not sure what you mean by your last two sentences. Please clarify.
Mar 07, 2018 07:38 AM|Brando ZWZ|LINK
If you include the bin and obj folder in the solution like this.
The application could also build well, but it may cause some error.
As my previous thread says, there are multiple reason will cause this error.
Since I couldn't reproduce the issue on my side, I could only give some possible reason.
Mar 07, 2018 02:15 PM|Yossu|LINK
Thanks for the clarification.
No, I don't have either of those folders included in my project.
Any other ideas? Thanks again
Mar 08, 2018 02:49 AM|Brando ZWZ|LINK
As far as I know, by default, when you compile a Web application the compiled code is placed in the Temporary ASP.NET Files folder.
This folder is a subdirectory of the location where you installed the .NET framework. Typically, the location is the following:
%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files
When ASP.NET runs your app for the first time, it copies any assemblies found in the /bin folder, copies any source code files (found for example in the App_Code folder) and parses your aspx, ascx files to c# source files. ASP.NET then builds/compiles all
this code into a runnable application.
I guess the folder is destroyed or with wrong file after windows updated.
This maybe the reason.