Skip to content

qwertykeith/EFAutoCodeFirstDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

example of doing awesome automatic EF code first

i probably should write a blog to explain this but haven't really got the time .. just look around.. it's pretty cool and should be understandable from the code.. then google stuff

change something in one of the models in the data project and run it again... see the magic

basic instructions to run locally

change the connection string in the webconfig to one you can use (don't change the name SomeDBContext)

p.s. yea yea.. no repository pattern here... it's just a demo of EF cod first awesomeness... still have to architecture it nicely

from scratch

  • create a database
  • optionally add a project with an entity data model
  • run enable-migrations -EnableAutomaticMigrations in the package manager on the db project
  • add the initialiser to the startup in global.asx (maybe keep the code in the db project and call it from global.asax)
  • (or for manual updates do Update-Database every time)
Database.SetInitializer(new MigrateDatabaseToLatestVersion<SomeDBContext, Configuration>()); 

Links

About

example of EF code first with AutomaticMigrationsEnabled

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published