8

I am using Entity Framework Core in my project , Created a DbContext class using the command

PM> Scaffold-DbContext "Server=servername;Database=DBname;User Id=user;Password=password;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context QuestionnaireEntities -Tables Category_Master,Item,Option_Master,Question_Master,Sub_Category_Master,Sub_Item

It is Creating DBContext Class perfectly , But if i want to update my DBContext from database than how i can do it in EFcore , In EF its easy just by doing right click and selecting option update from Database

Additionally how can i use stored procedure in my DBContext class

on msdn website they mentioned a command

PM> get-help scaffold-dbcontext –detailed

But it does not have any info about updating DBContext and adding stored procedure in it

How can i do that in EF Core I am using VS 2017 Community edition with .Net core 2.0 and EFcore 2.0

2 Answers 2

5

You can re-scaffold with -f/--force flag and this will overwrite existing files.

Sign up to request clarification or add additional context in comments.

Comments

1
This is simple query just run this in console here you can mention dbcontext if 
you have multiple dbcontext files.  
Scaffold-DbContext "Server=servername;Database=dbname; 
User ID=userid;Password=password; MultipleActiveResultSets=true;" 
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force -context 
DbContext 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.