0

I have followed the example from Microsoft documentation for a simple code first approach on a .NET Framework database generation. I checked my data source and confirmed it works as when I go to add a new data connection via Microsoft SQL Server the name of my configuration File shows up under the drop down for available tables.

When I test the connection to my table I get a successfully response.

When I click to add the new data connection I get the following error:

enter image description here

Previously I was able to connect to some other local databases like Northwind and other simple test databases, but not when ever I try to connect to any db I get this error. I tried in a VM as well and still get the same error.

Any suggestions?

EDIT: connection string:

connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=Proj.TestDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"

EDIT 2: When running a query in SQL Server Management Studio, I am able to see the generated tables and can even see how the code populated them (I had a simple add statement as a test). But for some reason I can not add it as a db connection in Visual Studio 2019

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
James_B
  • 137
  • 7
  • Can you post your connection string (with the server/password masked) – Neil Aug 17 '21 at 18:03
  • @Neil Just added it – James_B Aug 17 '21 at 18:04
  • Your connection string appears to be for a local SQL Server instance. Do you have this installed on the machine the code is running on? This is NOT the same as SQL Express. – Neil Aug 17 '21 at 18:06
  • @Neil yes, I have msql installed and earlier this week I was able to connect to other dbs hosted on the same spot using it without issues. – James_B Aug 17 '21 at 18:07
  • So was it working and now it isn't? Or has this bit never worked? – Neil Aug 17 '21 at 18:08
  • I was able to access data that I created using SQL. This is my second time trying with Entity Framework. The first time it worked, now it does not. Since trying this time I can not access any local databases even ones I previously could. Just 2 days ago I was playing around with a SQL generated db and was able to connect fine. Now that project is not able to connect to the same table it was working on. The only difference between then and now is this is my first time trying code first entity framework and now I can not access any database. – James_B Aug 17 '21 at 18:11
  • I've added an answer about connecting to DB. Please check out the edit section and let me know if you still face the issue. Here's the link. https://stackoverflow.com/questions/23154763/visual-studio-code-map-unable-to-connect-to-the-specified-database/23596081#23596081 – InsParbo Aug 17 '21 at 18:18
  • @InsParbo That covered .net core, but I looked at the documentation and my connectionString is fine. I also hoped on msql manager and ran some queries. My code is able to interact with the db. Like I can add, delete and query the db. I just can't have the db be shown in the server explorer. If it was a connection String issue I do not think I would be able to modify the db from the code. – James_B Aug 17 '21 at 19:11
  • @James_B, oh I thought you can't access any db as you wrote above. Also, .Net Framework has similar settings. Have you tried culture settings? https://learn.microsoft.com/en-us/aspnet/config-builder – InsParbo Aug 17 '21 at 19:44
  • @InsParbo No, I am not sure what I would do with them though as this is a simple console app. – James_B Aug 17 '21 at 19:47

0 Answers0