c# - Why is EDM class a partial class -


i added new ado.net edm item in visual studio porject.

using system; using system.data.entity; using system.componentmodel.dataannotations.schema; using system.linq; using system.diagnostics;  namespace rajat.personal.ef {     public partial class practicecontext : dbcontext     {         public practicecontext()             : base("name=localcontext")         {             this.database.log = s => debug.writeline(s);         }      public virtual dbset<user> users { get; set; }      protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         modelbuilder.entity<user>()             .property(e => e.firstname)             .isunicode(false);          modelbuilder.entity<user>()             .property(e => e.lastname)             .isunicode(false);          modelbuilder.entity<user>()             .property(e => e.emailaddress)             .isunicode(false);          modelbuilder.entity<user>()             .property(e => e.password)             .isunicode(false);     } } 

}

i have 2 questions

  1. why practicecontext partial class?
  2. why users property virtual ?

it generated partial class can extend class in separate file , avoid losing edits you've made when context next regenerated.

it uses virtual on properties can override them in inherited class provide alternative behaviour.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -