Local database in visual studio 2015 ASP.NET web application - sql

NET web application project.
There is little website of books and I want to save the names of books and authors into the database.
I ask if it's possible to create a local sql server database in the project and to save the books here.
I'm newbie to Web programming.
For example,in Android studio there was SQLite database and SQLiteOpenHelper classes where I was able to create local database in the project.
Is it possible in Visual studio 2015?

We got a project called local database - SQL Server Compact Database (*.sdf) in visual studio u can make use of it.
(a) In Solution Explorer,right-click on your application then select "Add" -> "New Item".
(b) Go to "Data" -> "Local database" then click on the "Add" button.
(c) Then go to the Server Explorer then expand your database ("MyDB.sdf") then right-click on "Table" then select "Create Table".
(d)And u'll end up in wizard for creating table or for other operations.
This link helps you to set it up.
http://www.c-sharpcorner.com/UploadFile/7d3362/curd-operation-in-local-database-sdf-file-in-window-appli/

Related

How to open database diagram in Visual Studio 2017

In Visual Studio 2017, I can not make relations between tables using database diagram.
How to open database diagram in Visual Studio 2017?
Database diagrams in xsd format can be opened in Visual Studio.
I Created and worked with Database Diagram xsd format using Visual Studio 2019 (can do same in VS 2017) in the following manner: -
Open Visual Studio and create a new C# console application (you can also use VB)
Go to “Solution Explorer” and right click on the Project and choose Add > New Item from sub-menu
from the pop up window, choose Visual C# project type as "Data" and select Dataset
Select main menu View > SQL Server Object Explorer to connect and view the desired SQL database objects.
Connect using credentials to view database objects like Views, tables etc.
To draw the database diagram, drag the required tables to the Dataset Pane
As per this similar question on MSDN, the database diagrams have been deprecated after Visual Studio 2012.
The answer there provides two workarounds:
You can use SQL Server Management Studio (SSMS) to work with Database diagrams, here is a download link.
You can add a item (ADO.NET Entity Data Model) to project, it will create for you a .edmx file which contains a table with relation. More in here.

Generating entity relationship diagram in Visual Studio 2015

Can you tell me how I can generate an ER diagram for my database1 (see below) created with VS 2015
Thanks in advance
Ensure you installed either Microsoft SQL Server Data Tools or Microsoft Web Developer Tools in order to get the Entity Data Model Designer.
These are the steps to generate entity relationship diagram. It was tested in VS2012
Open Visual Studio
Create a project or open an existing project
(must be Visual Basic, Visual C# project, or Console Application)
Right-click the project and choose Add -> New Item…
Under Visual C# Items select “Data”
Select the template “ADO.NET Entity Data Model”
Give it a name and click “Add”
Select “Generate from database” or “Empty model”
If “Generate from database” selected enter connection
info, choose the database objects and done!
The model is stored as a “.edmx” file.
With Visual Studio you can create a static diagram (class diagram) but not entity relationship diagrams (for you DB).
You will have to use another tool for this. For SQL server you can use SQL server Management Studio.
DB Objects in the editor will be related as in Diagram so Just relate objects in the Db and drag to editor.

SSMS 2008 R2 - Create Table Dialog

I just recently upgraded to SSMS 2008 R2, and I'm working with a few Azure databases in our development environment.
I was surprised to see that, when I right click on the Tables folder and click New Table, a new query window is opened with a predefined CREATE TABLE script template, rather then the more UI friendly "design view" that I'm used to seeing.
My question :
Is there any way to enable the design view for creating tables?
Your best bet is to use SQL Server Data Tools for Visual Studio 2010 - 2012.
Unlike SSMS 2008 R2; this still allows you to access the Design view for a Windows Azure SQL Database.
As indicated here you don't need to have Visual Studio installed initially to use the tools; it will install the Visual Studio Shell for you.
To do so:
Install SSDT
Open Visual Studio
On the left you should have a tab called "SQL Server Object Explorer" (If it isn't there, you can find it under the View menu on the top bar)
Within the tab; right click on SQL Server and click "Add SQL Server"
Enter you SQL Azure connection details
Once the connection has loaded; open the Tables folder inside the database
Right click the desired table and click "View Designer"

Database Projects: Visual Studio 2008 vs 2010

I just installed VS 2010 for the purposes of running someone else's DB project that was created using the 2010. In VS 2008 I was able to right click on a SQL file ans select "Run ON" to run the script on a given SQL Server. I don't see this option in 2010. Is it available and if so how do I get access to it?
The database project format that was included in VS 2005 and VS 2008 has been completely removed in 2010.
Rather than holding loose SQL files that could be run independently, it acts a bit more like a compiler. When the project is built, the SQL files are parsed and (for the most part) turned into an XML-description of the database schema.
If you're trying to create or update a database based on all of the scripts in the project, right click on the project name in Solution Explorer and select "Properties". Under the Deploy tab youchange "Deploy Action" to "Create a deployment script and deploy to the database". Specify the connection settings and database name.
When you select "Deploy" on the right-click context menu of the database project, Visual Studio will build the database deployment files and generate the database. It's generally intelligent enough to update existing databases as well, assuming the project was designed well.
If you're attempting a remote deployment to a production SQL Server, things get a bit trickier. There is no single set of SQL files you can run - part of the database schema is stored as XML.
Take a look at Link - it describes how to use the "vsdbcmd.exe" utility to deploy a database file.
If you just want to run a single SQL file or test part of one, open the file, right click, and select "Execute SQL"
DNRTv # 167 talks about VS 2010 Database Projects in detail.
As #ShadowChaser already mentioned, DB Project in VS 2008 simply had the scripts in it, and 2010 version is a lot more complex and has a lot more features.

How to create database project from existing SQL Server database?

By using VS TFS Database Edition 2008, how to create dbproject from an existing SQL SERVER database?
This as updated in VS 2010. There is now the option to "Import database objects and settings" from the project context menu.
In "Visual Studio" go to the "SQL Server Object Explorer" locate to database, right-click on the database you want and select "Create New Project ..."
There no direct, built-in support to do that, unfortunately.
You can get close by doing this:
in SQL Server Management Studio, go to the Object Explorer, right-click on the database you want, and pick Tasks > Generate Scripts
select all the database objects you want to script out
at the end, choose to generate the scripts into separate files for each db object
What you end up with are a number of .sql scripts in a folder of your choice, which basically represent your database.
Next:
create a Database Project in Visual Studio 2008
once you've done that, add the existing scripts to that project
It's a bit more involved that it should be - but that's the only way that I know of to achieve this right now. Don't know if VS2010 will support this in an easier way....