I am using an MVC Application that works with Unity to register all the dependencies of my project. I am also using Entity Framework for the DAL. In my local machine the application is running fine but at the time I deployed on the server I am receiving an error when Unity is trying to resolve the dependencies.
The underlying provider failed on Open. ... At the time of the exception, the container was: Resolving Class mapped from IClass ... Calling constructor of MyDbContext(System.String connectionName)
1- Does this have a relation with the connection string structure?
Bellow is my connection string
<add name="DBConnection" connectionString="Server=MyServer;Database=MyDatabase;Trusted_Connection=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
At this moment I don't have the access to the DB to check if the IIS user has the privileges on the server to run any query, but supposing it doesn't, does this has any relation with the error at the time Unity is trying to resolve the connection string?
2- Does Unity try to open a connection to the DB once it tries to resolve the DBContext?
Here is how I am injecting the parameters
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
container.RegisterType<IUnitOfWork, MyDbContext>(
Activator.CreateInstance<T>(),
new InjectionConstructor(connectionString));