NerdDinner is a small application, and our data storage
needs with it are pretty simple. We want to be able to define and store
“Dinners” that refer to specific events that people can attend. We also
want to be able to define and store “RSVP” acceptances, which are used to track
a person’s interest in attending a particular Dinner.
Let’s create two classes (Dinner and RSVP) to represent
these concepts. We’ll do this by adding two new classes to our ASP.NET
MVC project - “Dinner” and “RSVP”:
The above “Dinner” and “RSVP” model classes are “plain old
CLR objects” (aka POCO). They do not need to derive from any base classes
or implement any interfaces, and the properties they expose are standard .NET
data-types. No data persistence attributes or data code has been added to
them.
The ability to define model classes without having to tie
them to a particular database, database API, or database schema implementation
is really powerful – and provides us with much more data access
flexibility. It allows us to focus on our application/business needs
without having to worry about persistence implementation. It also gives
us the flexibility to change our database schema or storage implementation in
the future – without having to re-write our model objects, or the code that
interacts with them.