I have a few projects (I'm trying to connect to a local DB):
- DB_API project (C# project) using EF to connect to DB
- NativeCallingCLR.MixedDLL (C++/CLI) - IL bridge to invoke C# DB API methods
- NativeCallingCLR.Native (C++) - Implementing the API from C++/CLI to connect to the DB
This project structure is based on: https://www.codeproject.com/Articles/35041/Mixing-NET-and-native-code
I'm trying to configure EF to connect not with running assembly configurations but with other configurations/ Create a config file to the native c++ project.
I have tried to configure the connection like this:
Creating a class structure like this:
public partial class ABC : DbContext
{
public ABC(DbConnection conn) : base (conn,true)
{
}
}
And then creating the DbConnection object like this:
public int CreateConnection(string DBConnectionString, string DBProviderName)
{
var conn = DbProviderFactories.GetFactory(DBProviderName).CreateConnection();
conn.ConnectionString = DBConnectionString;
db = new ABC(conn);
return _PASS;
}
And I'm calling CreateConnection with these arguments:
DBConnectionString="metadata=res://*/InDBM.csdl|res://*/InDBM.ssdl|res://*/InDBM.msl;provider=System.Data.SqlClient;provider connection string='data source=localhost;initial catalog=Mycatalog;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework'"
DBProviderName="System.Data.EntityClient"
These arguments worked fine when I have tried to connect with an app.config and a C# running assembly but when I have tried to connect with creating the Dbconnection object this method failed.
Anybody have idea what I'm doing wrong here?