C# – Creating a Database and an Entity Model in Visual Studio 2013

Creating Database
LocalDb – Local dev-only version of SQL Server
Project -> Add New Item…. -> Installed -> Data -> Sql Server Database

Createa an .mdf file
SQL Server Data Tools (SSDT) -> Tools to create and manage SQL Server databases from Visual Studio.

Creating an Entity Model
Entity Data Model – Object Relational Mapper to treat database tables w/columns as classes w/ properties.

Project -> Add New Item…. -> Installed -> Data -> ADO.Net Entity Data Model -> Entity Data Model Wizard -> EF Designer from Database -> Connection -> Database Objects

DbContext == Handle to the entity model > database
DbSet == Collection of all entities in the DBContext

CarsEntities db = new CarEntities();
var dbCustomers = db.Customers;

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: