How to fix the "Code generation for property 'Connection' failed" error?
Last modified:
Q:
How to fix the "Code generation for property 'Connection' failed" error?
A:
Metadata provider for third-party DB connection may fail to load if you add an instance of it to the form due to the release of a newer version of this DB connection assembly. It happens because of the lack of assembly binding redirection, not in your project, but in the Visual Studio IDE itself.
To avoid such problems we regularly update references to third-party assemblies in our metadata providers. The problem is that we have to make this manually as newer versions of third-party assemblies may drop support for older framework versions that we claim to support. After we update this reference in the metadata provider, this error disappears but this situation may happen again in the future.
To avoid this error completely, you can create instances of such metadata providers in run-time.
Note: Automatic binding redirection should be turned on or manual assembly binding redirection should be set up properly. Please read these MSDN articles for details:
A great article explaining "what should I do if" can be found here: Assembly Binding Redirect to a lower version.