LocalDB and Entity Framework 6 - Security

旧时模样 提交于 2019-12-12 12:24:21

问题


I am trying to figure out a way to use a LocalDB in place of SQL for integration testing of EF6 queries (this would allow us to run integration tests on our build server). It seems like I should be able to replicate my database in SQL Express, detach, and import into my test project. I would expect from there I can modify my connection string in my test project to hit the local database file. I am running into a security issue though. I need to get SQL security working to pass in a user id and password in my conn string (since the build server will not be using my domain account), but regardless of what I try I get a bad username or password error as soon as I try to query. My connection string looks like this:

    <add name="ClinicalContext" connectionString="metadata=res://*/ClinicalDataStore.csdl|res://*/ClinicalDataStore.ssdl|res://*/ClinicalDataStore.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ClinicalDataStore.mdf;Integrated Security=False;User Id=SomeUser;Password=SomeUsersPassword;&quot;"
  providerName="System.Data.EntityClient" />

Does anyone have any experience with this and know if I need to do something particular to get sql security to work this way?

Update I attached the database file via Server Explorer and checked the updated connection string. The only change was to add an Initial Catalog and change the security back to integrated. If I try to connect that way, I get an error that it cannot access the catalog as the defined name. If I change back to sql security I still get the bad username or password error.

来源:https://stackoverflow.com/questions/23500862/localdb-and-entity-framework-6-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!