c# - MSDN Entity Framework Code First Tutorial: SQL Error -


i going through this tutorial on msdn. code in first part of tutorial.

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.data.entity;  namespace codefirstnewdatabasesample { class program {     static void main(string[] args)     {         using (var db = new bloggingcontext())         {             // create , save new blog              console.write("enter name new blog: ");             var name = console.readline();              var blog = new blog { name = name };             db.blogs.add(blog);             db.savechanges();              // display blogs database              var query = b in db.blogs                         orderby b.name                         select b;              console.writeline("all blogs in database:");             foreach (var item in query)             {                 console.writeline(item.name);             }              console.writeline("press key exit...");             console.readkey();         }     } }  public class blog {     public int blogid { get; set; }     public string name { get; set; }      public virtual list<post> posts { get; set; } }  public class post {     public int postid { get; set; }     public string title { get; set; }     public string content { get; set; }      public int blogid { get; set; }     public virtual blog blog { get; set; } }  public class bloggingcontext : dbcontext {     public dbset<blog> blogs { get; set; }     public dbset<post> posts { get; set; } } } 

compiling this, according tutorial should give me this:

enter name new blog: ado.net blog
blogs in database:
ado.net blog
press key exit...

but instead unhandled sqlexception:
create database permission denied in database 'master'.

is tutorial missing crucial information or there wrong setup?

edit: colleague said missing connectionstrings in app.config.

after adding:

<connectionstrings>     <add name="blogcontext" connectionstring="server=(localdb)\v11.0;integrated security=true;" providername="system.data.sqlclient"/>  </connectionstrings> 

the console application ran, , able see multiple blog entries when running program again. next step in tutorial says connect through server explorer, neither ((localdb)\v11.0) or (.\sqlexpress) appear options.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -