Database Reference
In-Depth Information
versus having the user or developer use SQL Scripting or develop the messages through
the SQL Management Studio.
This will be a basic understanding of EF, and for more details, please refer to ht-
tp://www.slideshare.net/rhelton_1/asp-mvc3-rev009 .
To create tables in code through EF, the generic DbContext is used. The DbContext
is a generic database context used to perform operations on the database. The best way to
think of DbContext is a session database context created by a connection string, and no
connection string will default to the local database. A DbContext article for working
with the context can be found at http://msdn.microsoft.com/en-us/data/jj729737.aspx , but
this example will work as it is.
In our example, we will extend the DbContext to tell it which sets of the database we
will be creating a database to handle.
You will see that the namespace is MVCApp1 , the extended database context is AppCon-
text , and the table is be filled with Paymessage objects; so, the namespace will be
used as this is a lot of work. We will use AppContext to create the database and tables
from code. When we run the code, without any model, we will get the tables and database
filled.
Creating tables from EF models
An alternative to creating sample messages in straight EF code is to have generated EF
models create the sample messages table. Here are some basic steps from a current data-
base.
Search WWH ::




Custom Search