Visual Studio 2012 MVC Local DB Add Table menu option missing - asp.net-mvc

Usually connect to an external database but I wanted to fiddle with creating a project with a local database. I am using SQLServer Express Local Database, not CE.
I can add tables with EF but if I right click on Tables in Server Explorer the only options I have are Refresh and Properties, i.e. no Add Table menu option. Similarly, if I right click on one of the tables EF has created I also get only the Refresh and Properties menu options so I can't add rows, etc. Same problem with stored procedures; I can't add any (should I want to do some testing with EF and stored procedures) because I only have the Refresh and Properties menu options.
FOLLOW UP:
I have isolated this problem to VS2012 Professional. When I use VS2010 it works exactly as expected: I can add tables and stored procedures. Following the same steps with VS2012 results in the situation where there is no menu option to add either tables or stored procedures. I produced these test results with SQLServer 2012 LocalDB.

If you only see Refresh and Properties when you right click on Tables in Server Explorer, you probably need to install SQL Server Data Tools from http://msdn.microsoft.com/en-us/data/hh297027 .

I had a similar problem only with Visual Studio 2012 Express for Web following along with the "Getting started with ASP.Net MVC3" at www.asp.net. The tutorial used a Sql Server Compact edition but I have SQL Express 2012 so I changed the connection string to have the data source point at my local instance, .\SQLExpress2012. The app worked fine and was able to read and write to the database. However I could not edit the database in the Visual Studio Express Database Explorer (all the context menu options were missing except "refresh" and "properties).
I found that changing the data source in the connection string to "Data Source=(LocalDB)\v11.0;" fixed the problem. I read somewhere that if you use LocalDb instead of the SQL Server instance name then it will be accessed under your user account - must have been some kind of permissions issue.
The whole (working) connnection string is:
"Data Source=(LocalDB)\v11.0;AttachDBFilename=|DataDirectory|Movies.mdf;Integrated Security=True;"
Hope this saves someone a bunch of hours pulling their hair out, I'm almost bald now :)

I found that when installing Visual Studio 2013, I had not requested the 'SQL Server Data Tools' feature.
By re-running the installer from 'Control Panel' > 'Programs and Features', using the 'Modify' option, I could add the missing feature. On completion, the 'Add New Table' menu item was available.

Related

Can't connect to SQL Server in Delphi 10.3

I just installed the community version of Delphi, Delphi 10.3
I want to use FireDAC in stead of ADO,
so I want to test connections to SQL Server using FireDac but it is a complete disaster.
I dropped a FDConnection component on the form, and want to configure it to use Sql Server
There I notice I can choose from many DriverNames but not MSSQL
Why is that ?
So I tried the FireDAC Explorer but this has even more mysteries.
I add a new Connection Definition and there I can use MSSQL, but I cannot save this definition.
The save and save as button are disabled.
So I enter all the parameters I need, and yes, it opens my SQL Server database. I can see all tables, views, procedures... And I can even open a table to see the first 10 rows.
Great, if I could only save this definition...
Everytime I open the FireDAC Explorer my new definition is still there, but all parameters are not stored. I have to enter them all every time again.
But, no problem I think. I copy the parameters from the working definition and paste it in the parameters from the FDConnection on my form.
The parameters look like this
User_Name=xx
OSAuthent=No
Server=123.456.789.987\GTT
Database=DB_Test
DriverID=MSSQL
Name=DB_Test
Hm, interesting. Now it does show MSSQL as drivername. So let's set the connection property to true.
Now I get this error (allthough this is working fine in FireDAC Explorer with these parameters)
[FireDAC][Phys]-300. Driver [MSSQL] is not registered. To register it,
you can drop component [TFDPhysMSSQLDriverLink] into your project.
Well alright, if that is all I need to do.
But, it seems I don't have the component TFDPhysMSSQLDriverLink
I have others for all kind of databases, but not this one.
It seems there is something missing, but the errors don't give me much of a clue
So I am hoping there is someone here that understand the errors and can help me to fix this
EDIT
I found this question here with an accepted answer, but I don't know how to use that answer. I have no clue how to use the License manager to register FireDAC

Where does ASP MVC - "Individual account authentication" project database gets stored?

I've encountered a strange thing...
I created a new project, with Individual account authentication authentication which creates a
DefaultConnection in Web.config.
I've also configured an oracle database connection, and commented the DefaultConnection.
Then I've registered a new user and data was saved in a hidden .mdf file that
was showed in App_Data after I've pressed "Show All Files" button in
Visual Studio.
I've deleted that .mdf file, Clean Solution, Build solution, Run project again -> login with same data and login still working
I'm very confused where did the app get's login data if no database exists with that info. Is it storing in another place that I don't know about?
It might be attached to local Db instance. Check Server Explorer to find if that is the case.If yes then you can delete the database from there.
I've found it eventually. Best way to make sure you see all databases on local device is to go to (in Visual Studio): View -> SQL Server Object Explorer -> Add SQL Server -> here you add all available servers (in my case was on my hostname\SQLEXPRESS)

nopcommerce 3.5 database connection string (settings.txt missing)

I have installed nopCommerce 3.5 on visual studio 2010 but after a successful configuration i could not find any database connection string file which should be under Nop.Web/App_Data/Settings.txt. so there is no Settings.txt file in my project at all and I am using MSSql 2012, Database has been created as expected including sample data. so where is my database connection string please?
Thanks for your time and help
Just create a file called "Settings.txt" in App_Data and copy the following 2 lines in it. You need to modify the connection string to suit your environment. I have replaced my details with capitals.
DataProvider: sqlserver
DataConnectionString: Data Source=SERVER_NAME\DB_INSTANCE;Initial Catalog=YOUR_DB_NAME;Integrated Security=True;User ID=USERNAME;Password=PASSWORD;MultipleActiveResultSets=True
refer this post : http://www.nopcommerce.com/boards/t/34563/where-is-database-connection-string-settingstxt-on-nopcommerce35.aspx
Its actually there, I had the same issue just now after installing 3.5 and wanting to point it at an existing db, but not being able to find settings.txt and wondering if it had been moved to web.config or something more usual.
What you need to do is highlight presentation > nop.web > App_Data and then click show all files in the solution explorer. there you will see Setting.txt . Right click it and select include in project and you are good to go.

mvc ef code first database creation map

was wondering if it's possible to point the visual web express to a specific folder when it builds the database using entity framework code first. this question stemmed from this one:
mvc connection string code first
anyway, i was able to successfully build the dbase using code first but sql server management studio is looking at a diff folder. is it possible to piont the web express to that folder when creating the database or is it better to just point the sql server management studio to where it's building it to? (does that make sense?) i tried fiddling with the ssms properties but it still won't look at that folder..
It whole depends on the connection string. If you are using default connection string for web application it always creates database in App_Data folder - it is specified by AttachDbFilename=|DataDirectory|DatabaseFileName.mdf. Using this is recommended way if you want your web app to create database because it should have necessary privileges by default.
If you want to place the database "elsewhere" you should not use attached db file and instead let SQL server create database in its default location by calling omitting AttachDbFilename part of the connection string. This can require additional security configuration to allow web application to create the database.

MVC 3 Adding a local Database

I am currently going through the MvcMusicSore tutorial (MVC 3). I have full sql server 2008 installed and created a local database by running the SqL scripts included in the MvcMusicStore-Assets data folder. However when trying to add the mdf to the AppFolder in Visual Studio 2010 I get the error Access Denied. I am completely stuck at this point and would appreciate any help to resolve this.
Most probably the mdf file is locked by some other process, not allowing the application to read it. If you mounted the database on SQL Server you need to use a connection string with the machine name instead of specifying the mdf file directly.
You can't copy or modify a live working database. And I don't see why you should.
You need connecting to it? Pick a way. LINQ to SQL, Entity Framework, NHibernate, ADO.NET...
If you really want to copy the database file for some reason, you must first stop the MSSQL Service (or detach the database), then do that.
Like others have said, you shouldn't need to add the actual .mdf into your project. If you have it running on your local SQL Server instance, you should be able to add it via Visual Studio's Server Explorer (plus that gets you your connection string).

Resources