entity framework - EF 7 Code first DB creation issue -


i followed tutorial on pluralsight asp .net 5 , ef 7 using code first db. connection string :

"worldcontextconnection": "server=cvu-octaviane\\sqlexpress;database=theworlddb;trusted_connection=true;" 

i added initial migration (which worked fine) , tried use ef 7 feature create db automatically: created context type class used database.ensurecreated() create db on first run. context class:

public class worldcontext : dbcontext {     public worldcontext()     {         database.ensurecreated();     }      public dbset<trip> trips { get; set; }     public dbset<stop> stops { get; set; }      protected override void onconfiguring(dbcontextoptionsbuilder optionsbuilder)     {         var connstring = startup.configuration["data:worldcontextconnection"];          optionsbuilder.usesqlserver(connstring);         base.onconfiguring(optionsbuilder);     } } 

when ran project "a severe error occurred on current command"

thanks

i had same problem , seem have resolved it.

i'm not sure if of below required, steps took

  • deleted migration .cs files under migrations folder
  • deleted theworlddb sql server object explorer
  • closed visual studio
  • upgraded asp.net 5 rc1 final @ get.asp.net
  • opened visual studio
  • updated global.json use "version": "1.0.0-rc1-final"
  • updated project.json use latest "dependencies"
    • "microsoft.aspnet.iisplatformhandler": "1.0.0-rc1-final",
    • "microsoft.aspnet.mvc": "6.0.0-rc1-final",
    • "microsoft.aspnet.mvc.abstractions": "6.0.0-rc1-final",
    • "microsoft.aspnet.server.kestrel": "1.0.0-rc1-final",
    • "microsoft.aspnet.staticfiles": "1.0.0-rc1-final",
    • "microsoft.aspnet.mvc.taghelpers": "6.0.0-rc1-final",
    • "microsoft.extensions.configuration": "1.0.0-rc1-final",
    • "entityframework.core": "7.0.0-rc1-final",
    • "entityframework.microsoftsqlserver": "7.0.0-rc1-final",
    • "entityframework.commands": "7.0.0-rc1-final"
  • ran dnvm install "1.0.0-rc1-final" , switched it
  • recreated migration dnx ef migrations add initialdatabase
  • executed project , worked

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -