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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -