ASP. NET MVC 5 tutorial: Using SQL Server LocalDB

Source: Internet
Author: User
Tags table definition

The Entity Framework Code first checks whether the database used by the connection string exists, and if it does not, automatically creates the database file. You can see if the database is created under the App_Data folder (if you don't see the movies.mdf file, click the Show All Files button on the Solution Explorer toolbar, click the Refresh button, and then expand App_Data folder).

Figure 1:movies.mdf File Location

Double-click the movies.mdf file, open Server Explorer, and then expand the Tables directory to view the Movies datasheet.

Figure 2: Server Explorer

Right-Movies The table and select "Show Table Data" To view the movie data we created.

Figure 3:movies the data in the table

Right-Movies The table and select Open Table definition to see the table structure created by the entity Framework Code first for us.

Figure 4:movies Table Structure

Entity Framework Code First automatically creates a table structure, including field names and data types, based on our movie class.

After we have finished viewing or editing the database, to close the connection in Server Explorer, right- moviedbcontext, select "Close Connection". (If you don't close the connection, you may get an error The next time you run the program)

Figure 5: Close the connection menu

Now that we have a database and a few simple pages to display the data, in the next chapters we will look at the code generated by the other scaffolding and add a Searchindex method and a Searchindex view to find the movie in the database.

ASP. NET MVC 5 tutorial: Using SQL Server LocalDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.