1

We need an option to set the ProviderManifestToken in code for a Database First Model in order to override the value from the EDMX, which defaults to "2012" for SQL Server 2012 in our particular case.

What we've tried so far: As described in this post we decorated our context class with the DbConfigurationType attribute, our derived class looks exactly the same as in that post.

internal sealed class MyDbConfiguration : DbConfiguration { public MyDbConfiguration() { //this.AddDependencyResolver(new SingletonDependencyResolver<IManifestTokenResolver>(new ManifestTokenService())); this.SetManifestTokenResolver(new ManifestTokenService()); } } 

As you can see, we tried 2 different things here, AddDependencyResolver and SetManifestTokenResolver.

When we start the application program execution enters the constructor of MyDbConfiguration - and that's it, the dependency resolver itself

internal sealed class ManifestTokenService : IManifestTokenResolver { private const string SqlServerManifestToken = @"2005"; private static readonly IManifestTokenResolver DefaultManifestTokenResolver = new DefaultManifestTokenResolver(); /// <inheritdoc /> public string ResolveManifestToken(DbConnection connection) { if (connection is SqlConnection) { return SqlServerManifestToken; } return DefaultManifestTokenResolver.ResolveManifestToken(connection); } } 

is never invoked so it seems we've reached a dead end here. Has anyone had the same problem and found a solution?

2
  • I was wondering if you ever found a solution to this? I need to do the same and just can't find a way to configure it in code. Commented Mar 8, 2016 at 23:57
  • Did you attach your DbConfiguration class to your object context? You can do it by adding this attribute. [DbConfigurationType(typeof(MyDbConfiguration))] Commented Sep 15, 2017 at 20:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.