For a new DB, the code-centric is simpler than it is for an existing database. Three ways of data access development:
(1) Database first – reverse engineer the Entity Model from the database schema. generate the entity class automatically from the EM using tools.
(2) Model first – Generate the Entity Model in the designer. Generate the database schema and entity classes from the EM.
(3) Code first – Define model and relationships in code. Create a new DB at runtime.
(1) connect to DB using .NET 4.5 data providers
(2) execute commands
(3) retrieve results
The list of ASO.NET data sources: MS SQL, Oracle.
WCF Data services enables CRUD operations on data using the Open Data Protocol (ODATA). WCF Data services will allow REST-style access to data models. Supports JSON and ATOM.
Entity Framework 5 – supports table-value functions and importing Stored Procs.
Now we have a data source, create a asp.net web site to consume the data.
Now add a asp.net web form application to your solution.
Press F5 and you should see a default web site. Close it.
Right click the project, add new item –>
Since you already have a DB, select generate from DB option.
Set up connection strings, and give the name “Entities”
In next screen, select the table, and give a Model name space of GadgetsModel.
In your solution explorer, if you only want to display elements related to a specific item (such as a folder), then right click the element, and click “Scope to this.”
After that you can manually edit the repeater with intellisense support!
Now you have this in web form:
Now edit the code behind.
Press F5 –>
You can also use EntityDataSource as a data source.
Drag to the form:
Select the Context:
Then set the data source of the repeater to this new data source.
You need to comment out the code in LOAD:
or else you will get a message that says it has already been defined.
Press F5, you get the same result using the EntityDataSource:
End of Chapter 1 – Page 25