1 / 13

Data Modeling Seminar

Data Modeling Seminar. February 18 , 2012 Lesson 7 Advanced Uses of Entity Framework. Recap. We’ve brainstormed our design We’ve created a database for our design We’ve normalized the database to optimize it

arama
Download Presentation

Data Modeling Seminar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data ModelingSeminar February 18, 2012 Lesson 7 Advanced Uses of Entity Framework

  2. Recap • We’ve brainstormed our design • We’ve created a database for our design • We’ve normalized the database to optimize it • We’ve created a Data Access Object, using Entity Framework, so that we can easily use our database in our application

  3. The Next Step • Now that we’ve got an advanced object that can read/write from/to our database, what else can we do with Entity Framework? • Let’s experiment!

  4. Walkthrough • Let’s make one more application. • Open up Visual Studio 2010.

  5. Walkthrough • From the 'File' menu select 'New' >> 'Project'. • Under Installed Templates, click on the Web category under Visual C#. • In the center panel, select an ASP.NET Dynamic Data Entities Web Application and then click OK.

  6. Walkthrough • Just like in the last lesson, we’re going to let Visual Studio create an Entity Framework model for us. • Right click on the project file and from the context menu, select Add >> New Item. • Under the Data category, select ADO.NET Entity Data Model and then click OK.

  7. Walkthrough • Select Generate from database and click next. • Find the ClassSchedule database we’ve been using and click next. • Make sure to check the boxes to include all Tables, Views, and Stored Procedures and click Finish.

  8. Walkthrough • In the solution explorer, find the Global.asax file and open it • Find the line that looks like this: DefaultModel.RegisterContext(typeof(YourDataContextType), newContextConfiguration() { ScaffoldAllTables = false}); • It is in the function RegisterRoutes • If you have line numbers turn on, look for line 30. • We want the Global.asax file to use the model we just created as the DefaultModel, so uncomment the line and change it to look like this: DefaultModel.RegisterContext(typeof(ClassScheduleEntities), newContextConfiguration() { ScaffoldAllTables = true });

  9. Walkthrough • Now save the Global.asax file and press “Ctrl + F5” to start the project without debugging • Note: By default, debugging is disabled for a Dynamic Data Entities Web Application. • What happens?

  10. Walkthrough • If you set up your Global.asax file correctly, Visual Studio should launch the home page for your Dynamic Data Entities Web Application.

  11. Walkthrough • Visual Studio has created a dynamic website, all with fully functional pages just by looking at our model (which was also created automatically). • In just about 5 minutes, we’ve gone from only having a database, to having a project that can access the database and a website that allows us to view, add, update, and delete data all from the browser.

  12. Walkthrough • It is outside the scope of this seminar, but if you want to take a closer look at how Visual Studio is creating this website on the fly, check out the DynamicData folder in your project. • In it, Visual Studio defines User Controls that can apply broadly to any kind of entity in your model.

  13. Wrap up

More Related