Entity Framework Linked database settings, entityframework
If you are not a student, learn EntityFramwork and make a record for your reference. Not to mention, go directly to the above steps
1. Add the following code snippet to WebConfig:
1 <connectionStrings> 2 2 <add name = "DefaultConnection" connectionString = "Data Source = .; initial catalog = EFModel; Integrated Security = false; User ID = sa; Password = sa; Connect Timeout = 1440; Pooling = true; MultipleActiveResultSets = True; "providerName =" System. data. sqlClient "/> 3 3 </connectionStrings>
2. Add a database context and inherit DBContext
1 public class EFDbContext: DBContext 2 {3 public EFDbContext () 4: base ("DefaultConnection") 5 {6} 7 8 public DbSet <Customers> Customer {get; set ;} 9 10 public DbSet <Company> Company {get; set;} 11}
Note: The base name in the database context must be the same as the WebConfig link string name.