Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

1. Building an ASP.NET MVC 4 Web Applica... > Interacting with a Database

Interacting with a Database

If you were to run the web application right now you would see a simple screen that displays a collection of guitar names. However, it’s still not very useful due to the data being hardcoded. Luckily, you have several choices when it comes to using F# to interact with a database for storage and/or retrieval of data.

Entity Framework

Entity Framework (EF) is probably the most common way to interact with an SQL Server database when working in ASP.NET MVC. Adoption is continuing to grow, especially now that EF supports a code-first approach. The F#/C# ASP.NET MVC 4 template already added all of the assembly references you need in order to start working with EF. With this done, you start using it by creating a class that inherits from DbContext. The following code shows an example of this:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint