• Complain

Rouleau - Beginning Entity Framework Core 2.0: database access from .NET

Here you can read online Rouleau - Beginning Entity Framework Core 2.0: database access from .NET full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA, year: 2018, publisher: Apress, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Rouleau Beginning Entity Framework Core 2.0: database access from .NET
  • Book:
    Beginning Entity Framework Core 2.0: database access from .NET
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2018
  • City:
    Berkeley;CA
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Beginning Entity Framework Core 2.0: database access from .NET: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Beginning Entity Framework Core 2.0: database access from .NET" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Use the valuable Entity Framework Core 2.0 tool in ASP.NET and the .NET Framework to eliminate the tedium around accessing databases and the data they contain. Entity Framework Core 2.0 greatly simplifies access to relational databases such as SQL Server that are commonly deployed in corporate settings. By eliminating tedious data access code that developers are otherwise forced to use, Entity Framework Core 2.0 enables you to work directly with the data in a database through domain-specific objects and methods. Beginning Entity Framework Core 2.0 is a carefully designed tutorial. Throughout the book you will encounter examples that you can use in your day-to-day coding, and you will build a solid foundation on which to create database-backed applications. If you are looking for a way to get started without getting buried under details you are only going to forget, then this is the book for you. The author aims to leave you comfortably able to connect to, access, modify, and delete data from a relational database. The book provides a clear, straightforward approach and includes code that you can look back at months later and understand. What Youll Learn: Study easy-to-follow, real-world examples you can use every day Focus on DbContext and the Database First approach Understand how to work with single and multiple tables Use the LINQ query language to manipulate data.;Introduction -- 1. Getting Started -- 2. Working with Multiple Tables -- 3. Stepping Beyond the Basics -- 4. Data Validation and POCOs -- 5. Stored Procedures, Table Design and Modifications -- 6. ASP.NET MVC and EF Core 2.0 -- 7. Finishing our ASP.NET MVC .NET Core 2.0 Project -- 8. Wrap-up and Where to Go Next -- 9. Appendix A: Database Script For Chapter 6.

Rouleau: author's other books


Who wrote Beginning Entity Framework Core 2.0: database access from .NET? Find out the surname, the name of the author of the book and a list of all author's works by series.

Beginning Entity Framework Core 2.0: database access from .NET — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Beginning Entity Framework Core 2.0: database access from .NET" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Derek J. Rouleau 2018
Derek J. Rouleau Beginning Entity Framework Core 2.0
1. Getting Started
Derek J. Rouleau 1
(1)
East Baldwin, Maine, USA
We are going to jump right into an example, as I think that is the best way to learn something. As we cover new topics, we explain them as we work on them. This is better than a general overview at the start of the chapter or section, because that wont mean much to you while you are reading it. I personally dislike it when books show you the wrong way of doing something and then show you how to do it correctly after you just spent five minutes typing in the wrong way, so Im not going to do that to you. However, I do explain why we are doing something and explain what would be wrong. Since this is a getting started type of book, all the examples work as written, although they may not be the best way of getting it done. As you get more comfortable with this technology and as your skills grow, youll come up with your own way of doing things. Im just here to help you started down the path to greatness.
For those of you who are like me and skipped the Introduction, you should be using the latest build of Visual Studio 2017 and at least .NET Framework 4.6.1. At the time of this writing, the latest build of Visual Studio was 15.3.3 with the .NET Framework build 4.7.02046. These build numbers can be found in the Visual Studio About window.
What Is .NET Core
Lets take a quick moment to cover something that some of you may be wonderingwhat is the difference between .NET and .NET Core? First off, .NET Core is cross platform, so if you want to run an application on Windows, Linux, or Mac, .NET Core is your tool. Due to its compact nature, .NET Core also gives better performance. The other nice thing is that you can always start with .NET Core and, if you find you need more features, you can switch to the full version of the .NET Framework. This is especially true if you are writing a service.
The application created here is used throughout the first section of this book and each section builds off the last, so you really cant skip around. With that being said, lets get started!
Setting Up Your Application
Follow these steps to set up the application:
Step 1: Create a new Visual C# Console App (.NET Core) Application in Visual studio called ComputerInventory . Again, make sure you are using at least .NET Framework 4.6.1 for your application.
Step 2: Open the NuGet package browser by clicking on Project Manage NuGet Packages (see Figure ).
Figure 1-1 Location of NuGet package manager Step 3 Add the following - photo 1
Figure 1-1
Location of NuGet package manager
Step 3: Add the following packages:
  • Microsoft.EntityFrameworkcore.SqlServer v2.0.0
  • Microsoft.EntityFrameworkcore.Tools v2.0.0
  • Microsoft.EntityFrameworkcore.SqlServer.Design v2.0.0
Note
As of the writing of this book, only the preview packages were available. If you cant find version 2.0.0, check the preview packages.
Figure shows what it looks like when you search for a package. Once you have selected the package you want to install, just click on the Install button to the right and click I Accept for any prompts that come up.
Figure 1-2 NuGet package manager That completes the basic setup of your - photo 2
Figure 1-2
NuGet package manager
That completes the basic setup of your application. Feel free to save your work before you continue.
Creating the Database and Tables (Entities)
If you have used Entity Framework 6.x or one of the other versions in the past, this next part will be a little new to you (or perhaps not). We are going to start with a code-first Entity Framework type of application, as that is somewhat easier when using EF Core. Later in the book, we use an application that is database-first, so you can see the difference. If you were to create an application based on an existing database, database-first is the choice youd probably use.
We are going to follow the model that is generally used by most people who design websites, so we need to create two folders in our application Models and Data . If you have never done this before, its simple. Just right-click on the ComputerInventory project in the Solution Explorer and select Add and then New Folder. Then change the name to Models . See Figure . Each of our eventual tables will have a corresponding class file in the Models folder. Ill take you step by step through the first one and then you should be able to create the remaining ones on your own (you just change the name of the class).
Figure 1-3 Adding a new folder Lets create our first class file Right-click - photo 3
Figure 1-3
Adding a new folder
Lets create our first class file. Right-click on the Models folder, select Add, and then select Class (should be at the bottom of the list). Make sure that Class is selected and change the name to OperatingSys.cs . Figure shows you what it should look like when you are creating the new class file. We are using OperatingSys rather than OperatingSystem , as OperatingSystem is a reserved type in C# and wed have to put Models.OperatingSystem in our code each time we wanted to use it.
Figure 1-4 Creating a new class Once you click on Add OperatingSyscs will - photo 4
Figure 1-4
Creating a new class
Once you click on Add, OperatingSys.cs will be created and load for you to start working on it. Listing shows the code for this new class.
using System;
using System.Collections.Generic;
namespace ComputerInventory.Models {
public partial class OperatingSys {
public OperatingSys() {
Machine = new HashSet();
}
public int OperatingSysId { get; set; }
public string Name { get; set; }
public bool StillSupported { get; set; }
public ICollection Machine { get; set; }
}
}
Listing 1-1
OperatingSys.cs After You Changed It
The first thing you need to remember is to make the class public so it will be accessible throughout the application. What we have done here is created the basis for the first table in that database, which we will call OperatingSys . In your table, its a good idea to have an ID field that is normally a primary key, and we have done that with OperatingSysID . You should have two errors, both telling you the same thing, that the type or namespace name Machine could not be found. That is correct, as you havent added them yet, so you can ignore this for now.
Two things should hopefully jump out at you. We have created a constructor for our class and within that, we have created a new HashSet called Machine . You dont need to use a HashSet here, but you do need to use a collection and since that is the default for EF Core we are going to stick with it for our examples.
If you are more familiar with EF Core and have the time, I highly recommend looking at the other set types as there are cases in which using a HashSet isnt needed and there is a better fit. We then have our ICollection , which provides an interface to the Machine table. After all, one OS could have multiple machines, but one machine generally only has one OS (we arent going to handle multi-boot systems in this simple example).
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Beginning Entity Framework Core 2.0: database access from .NET»

Look at similar books to Beginning Entity Framework Core 2.0: database access from .NET. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Beginning Entity Framework Core 2.0: database access from .NET»

Discussion, reviews of the book Beginning Entity Framework Core 2.0: database access from .NET and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.