I have automated test solution, which (lets say) contains 3 projects:
- DataAccessProject (which take data from db and thus can be called as producer, and it is my StartUpFile)
- PageObjectStorage
- Scenario and steps project What i am tring to do is to make 1. project use EF, without notifying any other projects that EF even exists in solution. I want (e.g.) my 3rd project to be able to call something like DataAccessProject.SomeMethod.GiveMeSomeUsers(), so DataAccessProject will take records from entity, do magic and simply return info to compare with values from page object.
What i am struggling with is: Firstly i was getting this error:
No connection string named 'MyEntities' could be found in the application config file
I have read some article on stack and added connection string node (i would like to avoid it), and now i am getting this error:
Errors: TestModel.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
So, my question is, what am i doing wrong? How can i install EF without adding references to EF in every project (i believe it is what EF wants from me now).
Related .config nodes:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="test1Entities" connectionString="metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MSSQL-TEST;initial catalog=testCATALOG;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" <providerName="System.Data.EntityClient" />
</connectionStrings>
For now i am calling this method from my 3 proejct
public static void TestMyEF()
{
using (var ctx = new test1Entities())
{
var abc = ctx.someTable.FirstOrDefault();
}
}
Context ctor:
public test1Entities()
: base("name=test1Entities")
{
}
P.s. i was using DB first approach (Create .edxm from exisiting DB), and i am a bit worried, cause my .config node contains <parameter value="mssqllocaldb" />
, DB is not local.