@@ -7,15 +7,15 @@ namespace ScaffoldingSample.Embedded.Contexts
77{
88 public partial class NorthwindSlimContext : DbContext
99 {
10- public virtual DbSet < Category > Category { get ; set ; }
11- public virtual DbSet < Customer > Customer { get ; set ; }
12- public virtual DbSet < CustomerSetting > CustomerSetting { get ; set ; }
13- public virtual DbSet < Employee > Employee { get ; set ; }
14- public virtual DbSet < EmployeeTerritories > EmployeeTerritories { get ; set ; }
15- public virtual DbSet < Order > Order { get ; set ; }
16- public virtual DbSet < OrderDetail > OrderDetail { get ; set ; }
17- public virtual DbSet < Product > Product { get ; set ; }
18- public virtual DbSet < Territory > Territory { get ; set ; }
10+ public virtual DbSet < Category > Categories { get ; set ; }
11+ public virtual DbSet < Customer > Customers { get ; set ; }
12+ public virtual DbSet < CustomerSetting > CustomerSettings { get ; set ; }
13+ public virtual DbSet < Employee > Employees { get ; set ; }
14+ public virtual DbSet < EmployeeTerritory > EmployeeTerritories { get ; set ; }
15+ public virtual DbSet < Order > Orders { get ; set ; }
16+ public virtual DbSet < OrderDetail > OrderDetails { get ; set ; }
17+ public virtual DbSet < Product > Products { get ; set ; }
18+ public virtual DbSet < Territory > Territories { get ; set ; }
1919
2020 public NorthwindSlimContext ( DbContextOptions < NorthwindSlimContext > options ) : base ( options )
2121 {
@@ -25,7 +25,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2525 {
2626 if ( ! optionsBuilder . IsConfigured )
2727 {
28- // #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http ://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
28+ #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https ://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263 .
2929 optionsBuilder . UseSqlServer ( "Data Source=(localdb)\\ MSSQLLocalDB; Initial Catalog=NorthwindSlim; Integrated Security=True" ) ;
3030 }
3131 }
@@ -34,16 +34,23 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
3434 {
3535 modelBuilder . Entity < Category > ( entity =>
3636 {
37+ entity . ToTable ( "Category" ) ;
38+
39+ entity . HasComment ( "hello table Customer" ) ;
40+
3741 entity . Property ( e => e . CategoryName )
3842 . IsRequired ( )
39- . HasMaxLength ( 15 ) ;
43+ . HasMaxLength ( 15 )
44+ . HasComment ( "hello CompanyName" ) ;
4045 } ) ;
4146
4247 modelBuilder . Entity < Customer > ( entity =>
4348 {
49+ entity . ToTable ( "Customer" ) ;
50+
4451 entity . Property ( e => e . CustomerId )
4552 . HasMaxLength ( 5 )
46- . IsFixedLength ( ) ;
53+ . IsFixedLength ( true ) ;
4754
4855 entity . Property ( e => e . City ) . HasMaxLength ( 15 ) ;
4956
@@ -61,9 +68,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
6168 entity . HasKey ( e => e . CustomerId )
6269 . HasName ( "PK_dbo.CustomerSetting" ) ;
6370
71+ entity . ToTable ( "CustomerSetting" ) ;
72+
6473 entity . Property ( e => e . CustomerId )
6574 . HasMaxLength ( 5 )
66- . IsFixedLength ( ) ;
75+ . IsFixedLength ( true ) ;
6776
6877 entity . Property ( e => e . Setting )
6978 . IsRequired ( )
@@ -78,6 +87,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
7887
7988 modelBuilder . Entity < Employee > ( entity =>
8089 {
90+ entity . ToTable ( "Employee" ) ;
91+
8192 entity . Property ( e => e . BirthDate ) . HasColumnType ( "datetime" ) ;
8293
8394 entity . Property ( e => e . City ) . HasMaxLength ( 15 ) ;
@@ -95,7 +106,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
95106 . HasMaxLength ( 20 ) ;
96107 } ) ;
97108
98- modelBuilder . Entity < EmployeeTerritories > ( entity =>
109+ modelBuilder . Entity < EmployeeTerritory > ( entity =>
99110 {
100111 entity . HasKey ( e => new { e . EmployeeId , e . TerritoryId } )
101112 . HasName ( "PK_dbo.EmployeeTerritories" ) ;
@@ -115,9 +126,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
115126
116127 modelBuilder . Entity < Order > ( entity =>
117128 {
129+ entity . ToTable ( "Order" ) ;
130+
118131 entity . Property ( e => e . CustomerId )
119132 . HasMaxLength ( 5 )
120- . IsFixedLength ( ) ;
133+ . IsFixedLength ( true ) ;
121134
122135 entity . Property ( e => e . Freight )
123136 . HasColumnType ( "money" )
@@ -128,50 +141,58 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
128141 entity . Property ( e => e . ShippedDate ) . HasColumnType ( "datetime" ) ;
129142
130143 entity . HasOne ( d => d . Customer )
131- . WithMany ( p => p . Order )
144+ . WithMany ( p => p . Orders )
132145 . HasForeignKey ( d => d . CustomerId )
133146 . HasConstraintName ( "FK_Orders_Customers" ) ;
134147 } ) ;
135148
136149 modelBuilder . Entity < OrderDetail > ( entity =>
137150 {
151+ entity . ToTable ( "OrderDetail" ) ;
152+
138153 entity . Property ( e => e . Quantity ) . HasDefaultValueSql ( "((1))" ) ;
139154
140155 entity . Property ( e => e . UnitPrice ) . HasColumnType ( "money" ) ;
141156
142157 entity . HasOne ( d => d . Order )
143- . WithMany ( p => p . OrderDetail )
158+ . WithMany ( p => p . OrderDetails )
144159 . HasForeignKey ( d => d . OrderId )
145160 . OnDelete ( DeleteBehavior . ClientSetNull )
146161 . HasConstraintName ( "FK_Order_Details_Orders" ) ;
147162
148163 entity . HasOne ( d => d . Product )
149- . WithMany ( p => p . OrderDetail )
164+ . WithMany ( p => p . OrderDetails )
150165 . HasForeignKey ( d => d . ProductId )
151166 . OnDelete ( DeleteBehavior . ClientSetNull )
152167 . HasConstraintName ( "FK_Order_Details_Products" ) ;
153168 } ) ;
154169
155170 modelBuilder . Entity < Product > ( entity =>
156171 {
172+ entity . ToTable ( "Product" ) ;
173+
157174 entity . Property ( e => e . ProductName )
158175 . IsRequired ( )
159176 . HasMaxLength ( 40 ) ;
160177
161- entity . Property ( e => e . RowVersion ) . IsRowVersion ( ) ;
178+ entity . Property ( e => e . RowVersion )
179+ . IsRowVersion ( )
180+ . IsConcurrencyToken ( ) ;
162181
163182 entity . Property ( e => e . UnitPrice )
164183 . HasColumnType ( "money" )
165184 . HasDefaultValueSql ( "((0))" ) ;
166185
167186 entity . HasOne ( d => d . Category )
168- . WithMany ( p => p . Product )
187+ . WithMany ( p => p . Products )
169188 . HasForeignKey ( d => d . CategoryId )
170189 . HasConstraintName ( "FK_Products_Categories" ) ;
171190 } ) ;
172191
173192 modelBuilder . Entity < Territory > ( entity =>
174193 {
194+ entity . ToTable ( "Territory" ) ;
195+
175196 entity . Property ( e => e . TerritoryId ) . HasMaxLength ( 20 ) ;
176197
177198 entity . Property ( e => e . TerritoryDescription )
0 commit comments