Saturday, November 5, 2022

ASP.NET6 command to scafold modules using an existing database

NOTE : Make sure Microsoft.EntityFrameworkCore.Design package should be added to your project.

dotnet ef dbcontext scaffold "Filename=dbname.db" Microsoft. EntityFrameworkCore.Sqlite --table tablename --table tablename --outputdir Foldername --namespace Namespace --data-annotations --context Dbcontext

Note the following:


• The command action: dbcontext scaffold
• The connection string: "Filename=Northwind.db" 
• The database provider: Microsoft.EntityFrameworkCore.Sqlite 
• The tables to generate models for: --table Categories --table Products 
• The output folder: --output-dir AutoGenModels 
• The namespace: --namespace WorkingWithEFCore.AutoGen 
• To use data annotations as well as the Fluent API: --data-annotations 
• To rename the context from [database_name]Context: --context Northwind

No comments:

Post a Comment

methods available in Dapper

  Dapper is a micro ORM library for .NET and .NET Core applications that allows you to execute SQL queries and map the results to objects. D...