Justin Case

Justin Case

  • NA
  • 6
  • 623

Entity Framework in DLL

May 23 2018 6:33 AM
I am creating a distributed C# application. One of the parts is a windows service. Another part is a core model dll, containing the classes for all parts of the app. It also has the connection to the DB through Entity Framework.
When i use the DLL in the windows service project and try to save an object to the database through the DLL, it uses the user credentials that the service is running on to access the db, even if I have specified a username/password in the app.config file of the DLL, like so:

<add name="TemplateDBContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=EMSCore;User Id=sa;Password=123" providerName="System.Data.SqlClient" />
 
How can I make sure that the credentials from app.config is always used? I don't want the service user to have DB access, only the hard coded user.

Answers (1)