asp.net mvc - Remove migration files and recreate Initial.cs -


i've been using migrations while now, , i've ended bunch of migration files. i've been having trouble seed method duplicates data (when trying use id "identifier"), when want create data once.

now thinking of removing migration files , recreating initial 1 tidy bit. planning on seeding data in up() method using sql(), instead of using seed() method.

i've got bunch of sites running paying clients. don't want risk ending in situation have chose not being able update db schema, , having drop clients data (that bad on part).

i feel unsure whole migration thing. i've had occurrences in stages of development migrations got screwed , had drop/recreate db.

so questions boils down to...will encounter problems updating running sites if remove migration files , recreate 1 big initial migration?

this current configuration.cs. i'm using option in web deploy "execute code migrations" on application_start():

internal sealed class configuration : dbmigrationsconfiguration<bandpage.models.bandpagecontext>     {         public configuration()         {             automaticmigrationsenabled = false;         }          protected override void seed(bandpage.models.bandpagecontext context)         {             list<sitesettings> sitesettings = new list<sitesettings>             {                 new sitesettings                 {                     title = "page title",                     metakeywords = "",                     metadescription = "",                     metalanguage = "en",                     favicon = "",                     footertext = "",                     backgroundimage = "",                     headerimage = "",                     footerimage = "",                     backgroundcolor = "255,255,255",                     containercolor = "0,0,0",                     containeropacity = 7,                     headingcolor = "0,0,0",                     textcolor = "0,0,0",                     linkcolor = "0,0,255",                     headingfont = "verdana",                     headingsize = "8",                     textfont = "verdana",                     textsize = "6",                     containerwidth = 800,                     customcss = ""                 }             };             sitesettings.foreach(s => context.sitesettings.addorupdate(i => i.sitesettingsid, s));             context.savechanges();              // add fonts database             list<font> fonts = new list<font>             {                 new font { name = "impact", fontfamily = "impact, charcoal, sans-serif" },                 new font { name = "comic sans", fontfamily = "'comic sans ms', cursive, sans-serif" },                 new font { name = "palatino", fontfamily = "'palatino linotype', 'book antiqua', palatino, serif" },                 new font { name = "tahoma", fontfamily = "tahoma, geneva, sans-serif" },                 new font { name = "century gothic", fontfamily = "century gothic, sans-serif" },                 new font { name = "lucida sans", fontfamily = "'lucida sans unicode', 'lucida grande', sans-serif" },                 new font { name = "arial black", fontfamily = "'arial black', gadget, sans-serif" },                 new font { name = "times new roman", fontfamily = "'times new roman', times, serif" },                 new font { name = "arial narrow", fontfamily = "'arial narrow', sans-serif" },                 new font { name = "verdana", fontfamily = "verdana, geneva, sans-serif" },                 new font { name = "cooperplate gothic", fontfamily = "copperplate, 'copperplate gothic light', sans-serif" },                 new font { name = "lucida console", fontfamily = "'lucida console', monaco, monospace" },                 new font { name = "gill sans", fontfamily = "'gill sans', 'gill sans mt', sans-serif" },                 new font { name = "trebuchet ms", fontfamily = "'trebuchet ms', helvetica, sans-serif" },                 new font { name = "courier new", fontfamily = "'courier new', courier, monospace" },                 new font { name = "arial", fontfamily = "arial, helvetica, sans-serif" },                 new font { name = "georgia", fontfamily = "georgia, serif" },                 new font { name = "helvetica", fontfamily = "'helvetica neue', 'lucida grande', helvetica, arial, verdana, sans-serif" }              };             fonts.foreach(s => context.fonts.addorupdate(i => i.name, s));             context.savechanges();               // add fixed pages "home", "contact" etc             list<menuitempage> menuitempages = new list<menuitempage>             {                 new menuitempage { pagename = "", pageid = 0, slug = "" },                 new menuitempage { pagename = "blog", pageid = 0, slug = "blog" },                 new menuitempage { pagename = "home", pageid = 0, slug = "" },                 new menuitempage { pagename = "contact", pageid = 0, slug = "contact" },                 new menuitempage { pagename = "shows", pageid = 0, slug = "tour" },                 new menuitempage { pagename = "store", pageid = 0, slug = "store" },                 new menuitempage { pagename = "image gallery", pageid = 0, slug = "gallery" },             };             menuitempages.foreach(s => context.menuitempages.addorupdate(i => i.pagename, s));             context.savechanges();          }     } 

why end multiple records of sitesettings? other ones work should. can't work when using id identifier. wan't create 1 row in sitesettings table (for initial values), , not create more rows.

the sites cms system every site has it's own sql ce database.

hope can take time me!

/mikael

entity framework should checking whether sitesettingsid exists in database. if database generated entity framework check whether 0 exists , if doesn't go ahead , insert data, insert.

the other addorupdates work because have specified natural key not database generated. add natural key sitesettings class


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -