PC Review


Reply
Thread Tools Rate Thread

How to create trivial CRUD app using data binding and Entity Framework?

 
 
Dan Mayolo
Guest
Posts: n/a
 
      16th Aug 2009
I tried following the steps I describe below in VS 2010, but to no avail:

· Create new Windows Forms App. Project

· Add new empty ADO EDM to Project

· Add new entity Customer with scalar properties FirstName and
LastName

· Generate db script with EDM

· Execute db script to create tables in the db

· Add new Object Data Source based on EDM Model1

· Select object Customer in Data Sources window and drop it on form
in form of Details view.

· All typical binding controls are created, all I need to do is to
enable the Save button.





I run the app, form is displayed. I can add new records and navigate between
them. I press save, but when I reinitialize the app, all data is lost. I
guess code on the form should only reference BindingDataSource, not the
ObjectContext directly?

I tried setting the customerBindingSource.DataSource = ctx.Customers and
saving changes via ctx.SaveChanges(), but still new entities are not added
correctly.

What is the minimum of the code I need to write to make this simple CRUD
example working?



Thanks!


Dan


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entity Framework - entity with multiple foreign keys to same table CGatto Microsoft ADO .NET 1 7th Aug 2009 07:51 PM
Entity Framework - Reassigning child entity's parent Norm Microsoft ASP .NET 3 6th Jul 2009 08:28 PM
Entity framework issue: Unable to create association on tables in TPTmodel rshillington Microsoft ADO .NET 0 16th Jan 2009 03:00 AM
binding and crud xml data source in asp.net J Ames Microsoft ASP .NET 1 9th Apr 2006 01:24 AM
binding and crud xml data source in asp.net J Ames Microsoft VB .NET 0 8th Apr 2006 10:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:34 PM.