Contact Form

Name

Email *

Message *

Entity Framework core Database First Approach .net 6

No comments

 


setp 1 :::::: 

Scaffold-DbContext "Data Source=.;Initial Catalog=CMS;Persist Security Info=True;User ID=swera;Password=1122333;" Microsoft.EntityFrameworkCore.SqlServer   -Context NWContext  -OutputDir Models/DB -ContextDir Models/Context  -Tables Account

setp 2 :::::: 

Update existing models

 Scaffold-DbContext "Data Source=.;Initial Catalog=CMS;Persist Security Info=True;User ID=swera;Password=1122333;"  -Provider Microsoft.EntityFrameworkCore.SqlServer   -Context NWContext  -OutputDir Models/DB -ContextDir Models/Context -Tables Aaa,Account  -Force

setp 3  ::::::  Add class CMSContextExt :::::: 

   public partial class CMSContext : DbContext

    {

    public virtual DbSet<MySPModel> MySP { get; set; } // your new DbQuery

    }

Sep 4  :::::: Call Proc 

  var mLoginUser = new SqlParameter("User", "admin");

    var mLoginPassword = new SqlParameter("Password", "admin");

            var empRecord = _logCMS.SpGetbyLogin.FromSqlRaw("EXEC dbo.SpGetbyLogin @User, @Password", new SqlParameter[] { mLoginUser, mLoginPassword }).ToList();


No comments :

Post a Comment