Using Database Initializers and seeding

Add the following code in global.asax.cs

protected void Application_Start()     
{
        Database.SetInitializer(new MyStoreDbInitializer());
        AreaRegistration.RegisterAllAreas();
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);     
}

Create the following class

public class MyStoreDbInitializer : DropCreateDatabaseAlways<MyStoreDB>    
 {
         protected override void Seed(MusicStoreDB context)
         {
             context.Artists.Add(new Artist {Name = “Al Di Meola”});
             context.Genres.Add(new Genre { Name = “Jazz” });
             context.Albums.Add(new Album
                                 {
                                     Artist = new Artist { Name=”Rush” },
                                     Genre = new Genre { Name=”Rock” },
                                     Price = 9.99m,
                                     Title = “Caravan”
                                 });
             base.Seed(context);
         }
     }

Comments (4) -

4/27/2012 9:32:12 AM #

Joseph Finkelman

Im not going to say what everyone else has already said, but I do want to comment on your knowledge of the topic.  Youre truly well-informed.  I cant believe how much of this I just wasnt aware of.  Thank you for bringing more information to this topic for me.  Im truly grateful and really impressed.

Joseph Finkelman United States

5/29/2013 2:44:31 PM #

Jenna

You made some prestigious points there. I did a search on the matter and discovered the majority of people will agree together with your blog.

Here is my web page -  Jenna - discerningdate.com/.../Ways-To-Get-Your-Internet-Web-Hosting

Jenna

5/31/2013 5:37:22 PM #

seo consultancy

I&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;m extremely concerned on this challenge. Where can I discover that only selective details about this? Or, should you usually do not pursue this additional right here.

Here is my webpage ...  seo consultancy - www.waagg.com/.../

seo consultancy

6/1/2013 7:12:12 AM #

click through the following web page

:O So mush selective facts :O … This really is the most amazing web site Dude… Laughing

Have a look at my web-site  click through the following web page - www.theproarticles.info/.../...Credit-Ratings.html

click through the following web page

6/1/2013 7:24:30 AM #

kredit vergleichen

My buddy and I argue about an problem with this one particular! Now I find that I was proper. lol! identified as the music so, be back: D

Here is my page -  kredit vergleichen - smokersgroove.com/.../

kredit vergleichen

6/1/2013 11:57:38 AM #

Henrietta

There&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;s obviously lots to know about this.  I guess you made some pleasant tips in Functions also.

Review my homepage ::  Henrietta - www.xn--diseoyprogramacin-ixb4c.com/.../85255

Henrietta

6/1/2013 12:25:51 PM #

Edna

You are functioning in this business? He seems to know a lot about the content.

Also visit my weblog  Edna - budstastny.cz/members/eddynorma/activity/68672

Edna

6/1/2013 4:07:49 PM #

mortgage lenders for bad credit

I saw the diary as Yahoo and read a few posts. prestigious job! I just twittered regarding the weblog

my web-site:  mortgage lenders for bad credit - www.szakibazis.com/.../Ways-To-Boost-Your-Credit-Score

mortgage lenders for bad credit

6/1/2013 7:32:18 PM #

Click On this page

Frankly, as the short article I am going back up.

Feel free to visit my web blog;  Click On this page - http://www.oresco.org/oxwall/blogs/post/68177

Click On this page

6/2/2013 12:43:38 AM #

Tracee

Your diary is so informative ... Preserve the prestigious exercising!

My web page ::  Tracee - victimsofslaveryandtorture.com/take-pleasure-vacationing-these-tips-ensure-it-enjoyable

Tracee

6/2/2013 1:55:22 AM #

Owen

Hi, what entice you to post an write-up. This short article was extremely diverting, particularly because I was seeking for ideas on content last Thursday.

Feel free to visit my web blog -  Owen - www.teamgeorgiawrestling.com/index.php

Owen

6/2/2013 3:50:41 AM #

die beliebtesten online shops

pleasant to find out you posting on this topic, I necessitate to bookmark this website. Preserve up the very good function.

Check out my web blog -  die beliebtesten online shops - www.nmwws.org.np/index.php

die beliebtesten online shops

6/2/2013 8:14:30 AM #

affiliate networks list

Hello. I read a few of one&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;s other posts and wanted to give thanks you

Also visit my weblog ...  affiliate networks list - www.Clavio.de/.../marketing_methods_for_advanced_affiliates

affiliate networks list

6/2/2013 1:43:58 PM #

Felipe

Duperre super-site! I&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;m loving it! &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39; Will come back again - finding you to eat, give Thanks.

my web page;  Felipe - luke0785.jigsy.com/.../benefits-and-drawbacks-of-running-a-business

Felipe

6/2/2013 3:46:55 PM #

Marissa

Howdy, A real occupying record. Proceed it up.

Look into my blog post:  Marissa - www.clavio.de/.../discover_ways_to_achieve_success_at_internet_affiliate_marketing

Marissa

6/2/2013 5:44:43 PM #

visit this web page link

To begin producing revenue together with your web log, initially use Google Adsense but step by step as your targeted traffic increases, Retain adding more and more revenue making applications for your internet site.

my blog;  visit this web page link - www.waterleaf.eu/index.php

visit this web page link

6/2/2013 6:36:00 PM #

arbeitslos kredit

Frankly, as the write-up I am going back up.

Look at my web page:  arbeitslos kredit - shameme.net/.../techniques-for-making-credit-history-restoration-easy-and-swift

arbeitslos kredit

6/2/2013 7:34:08 PM #

what online business can i do

I in no way ever post but this time I will, Thanks quite a bit for the very good net log.

My webpage:  what online business can i do - http://www.playet101.com/?p=78696

what online business can i do

6/2/2013 11:27:42 PM #

similar resource site

Hey really Nice weblog!! Man .. Attractive .. awesome .. I will bookmark your weblog and take the feeds also...

My web-site:  similar resource site - sleeplessouldesigns.com/.../

similar resource site

6/2/2013 11:41:08 PM #

Neal

Hello to all Smile I can not recognize how to add your website in my rss reader.

Feel free to surf to my blog post ...  Neal - www.ofelon.org/.../

Neal

6/2/2013 11:43:54 PM #

home refinance bad credit

Good post Tong

my web site:  home refinance bad credit - http://www.michael-friedrichs.de/node/13571

home refinance bad credit

6/3/2013 1:33:05 AM #

free online business ideas

Hi webmaster I like the spot ....

Also visit my weblog;  free online business ideas - www.federationdesigncompany.co.uk/search.php

free online business ideas

6/3/2013 3:29:48 AM #

how do you qualify for a home equity loan

interesting article. Exactly where did you got all the data from... Smile

Here is my weblog  how do you qualify for a home equity loan - myrtlebeachmastermind.com/.../

how do you qualify for a home equity loan

6/3/2013 3:37:24 AM #

Robert

There&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;s obviously lots to encounter around this.  I look at you created some pleasant points in Characteristics also.

Also visit my web blog -  Robert - agrifarms.in/.../

Robert

6/3/2013 5:18:10 AM #

Shelli

Nice post!

my web page ::  Shelli - www.pensandoensig.com/.../index.php

Shelli

6/3/2013 6:20:24 AM #

William

Couldn’t agree additional! at your success

my blog post:  William - swiftlyfitness.com/.../

William

6/3/2013 11:29:39 PM #

national foundation for credit counseling

As a Newbie, I&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;m often searching on-line for articles that will assist me. thank you

Here is my weblog;  national foundation for credit counseling - www.pressace.com/...trategies-To-Assist-You-To.htm

national foundation for credit counseling

6/4/2013 5:22:12 AM #

Home Page

Not surprisingly, what a superior web site and illuminating posts, I&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;ll add back hyperlink - bookmark this web site? Regards

Feel free to surf to my web-site:  Home Page - Mangdienthoai.com/.../

Home Page

6/4/2013 5:31:03 AM #

affiliate marketing opportunities

I actually enjoyed your post. Will hyperlink back from my web-site. Please place additional frequently when you&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#39;ve got time. Thanks!

Take a look at my site -  affiliate marketing opportunities - forums.mabuhaydavao.com/.../

affiliate marketing opportunities

6/4/2013 6:19:45 AM #

private versicherungen vergleich

:O So a lot information and facts :O … This is one of the most amazing web page Dude… Laughing

Here is my webpage ...  private versicherungen vergleich - dayofwebsite.com/.../get-most-your-wellbeing-insurance-venture-using-these-ideas

private versicherungen vergleich

6/4/2013 12:01:18 PM #

urlaub machen in deutschland

prestigious to determine you posting on this theme, I ought to bookmark this web page. Preserve up the excellent work.

Also visit my page ...  urlaub machen in deutschland - http://www.socialtvm.com/blogs/post/21713

urlaub machen in deutschland

6/4/2013 3:26:12 PM #

billiger reisen nach t&#252;rkei

There is apparently a good deal to experience just about this.  I think you produced some critical tips in Capabilities also.

Review my web page  billiger reisen nach t&amp;amp;amp;amp;amp;amp;amp;amp;amp;#252;rkei - agrifarms.in/.../

billiger reisen nach türkei

6/4/2013 4:10:56 PM #

Juan

ohh ... Nice post but is it seriously? /? : P

Feel free to visit my web blog;  Juan - Connectback2.me/.../

Juan

6/4/2013 5:46:30 PM #

Allen

My friend and I had an argument about a subject like this! Now I find that I was ideal. lol! You decide, as the music that I will be back: D

Here is my website  Allen - lnx.icsci.it/moodle/blog/index.php?postid=51407

Allen

6/5/2013 12:41:38 AM #

bon kredit seri&#246;s

essentially Fine workout! I thoroughly enjoyed your article. Please place a lot more generally once you have time. Thanks.

Take a look at my site  bon kredit seri&amp;amp;amp;amp;amp;amp;#246;s - udelascienciasyelarte.ac.cr/index.php

bon kredit seriös

6/5/2013 12:55:53 AM #

Susanna

Blogs I normally does not happen, but it pushed me towards the blog, a fascinating exercise .. Stunning ...

my blog post:  Susanna - konannavi.org/.../index.php

Susanna

6/5/2013 4:31:49 AM #

private krankenversicherung kinder

I Preserve hearing for the news speak just about having free on-line grant applications so I&amp;amp;amp;amp;#39;ve been browsing around for the optimal site to get one particular.

Feel free to visit my homepage:  private krankenversicherung kinder - www.isleofwightfacebook.co.uk/.../

private krankenversicherung kinder

6/5/2013 5:10:45 AM #

Read Much more

Such a functional web log…wow !!!!

Review my web page;  Read Much more - www.freearticleavenue.com/.../...o-Understand.html

Read Much more

6/5/2013 3:23:43 PM #

Darrell

Normally I do not spot on blogs, but I would prefer to say that this place actually forced me to accomplish so! Essential post.

my webpage  Darrell - utopiaunite.com/.../Affiliate-Marketing-Methods-Beyond-The

Darrell