Skip to content
Loading
  • Ashutosh Gupta
    0
    Gcobani,
     
    what you are showing is your connection string. you need to use the below command to generate models using this connection string.   scaffold-DBContext .............. command will generate all tables into c# class and DBcontext class which will have respective properties etc.
    0
  • 0
    Hi Gupta
     
    Do i need to use this command via nuget on the console? 
    0
  • Ashutosh Gupta
    0
    yes nuget package manager console
    0
  • 0
    1. PM> scaffold-DBContext "Data Source="(LocalDb)\MSSQLLocalDB; Catalog=eNtsaOnlineRegistrationDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer-OutputDir Models  
    How do i then check the naming of my model?
    0
  • Ashutosh Gupta
    0
    you should be having new DBcontext and models classes generated in your solution. 
     
    verify Models folder in your solution if the below command was successfully executed. 
    0
  • 0
    1. scaffold-DBContext "Data Source="(LocalDb)\MSSQLLocalDB; Catalog=eNtsaOnlineRegistrationDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer-OutputDir Models  
    2. >>    
    Hi Gupta
     
    I am unable to see from the project folder under Model, my new DbContext. Have i done something wrong on my command? please assist, thanks. 
    0
  • Ashutosh Gupta
    0
    scaffold-DBContext "Data Source=(LocalDb)\MSSQLLocalDB; Catalog=eNtsaOnlineRegistrationDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer-OutputDir Models
     
    there was one extra ", check with this. it should be excuted without any error..
    0
  • 0
    Hi Mates
     
    I ran this new command, i was getting an error, please assist me thanks. Had to look at stackoverflow for these error and did some Install-Packges like EntityFrameworksTools and SqlServer. I had now new error while re -running same command.
     
     
     
     
     
    0
  • Ashutosh Gupta
    0
    i think there is no Models folder under your solution, create one with name Models and try.
    0
  • 0
    Hi Mate
     
    No there is unfortunately please see below for more information. After following Github still no luck even if i try to use this special command scaffold-DBContext "Data Source=(LocalDb)\MSSQLLocalDB; Catalog=eNtsaOnlineRegistrationDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer-Verbose it does not compile successfully.                                                                                                                                                                                                                                                                                                        Ok i Re ran the command putting the space after SqlServer and got this error, scaffold-DBContext : Exception calling "Start" with "1" argument(s): "The system cannot find the file specified". 
    1. PM> scaffold-DBContext "Data Source=(LocalDb)\MSSQLLocalDB; Catalog=eNtsaOnlineRegistrationDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer  -Verbose  
     
    0
  • 0
    I got rid of this error, but the problem im still unable to see new Model class under my folder. How i fix it its below install-package Microsoft.EntityFramework.Tools v 3.1.1
    0
  • Ashutosh Gupta
    0
    i think, it is case sensitive, make sure you type correctly S is captial in Scaffold
     
    Scaffold-DbContext  
    0
  • 0
    1.   
    2.     "eNtsaOnlineRegistrationDB" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\eNtsaOnlineRegistrationDB.mdf;Initial Catalog=master; Integrated Security=True" providerName="System.Data.SqlClient" />  
    3.     
    Hi Gupta
     
    I did that was missing an package, of which is i am now getting  Keyword not supported 'catalog'. Busy looking at this issue,dont know if my connectionString is correct
    0
  • 0
    Hi Mate
     
    I got this link from CodeProject, had to follow the documentation from step 2 step, missing update of the package seemed relevant and had to re do the command putting -OutputDir Models all were executed well no error. After the update though for the Install-Package Microsoft.EntityFrameworkCore.Tools.
     
    https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell 
    0