I am not, learning entityframwork at the same time make a record for everyone to reference. Not much to say directly on the steps
1, add the following code snippet in Webconfig
1 <connectionStrings>22 <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 "/>33 </connectionStrings>
2. Add a database context and inherit DbContext
1 Public classefdbcontext:D Bcontext2 {3 PublicEfdbcontext ()4:Base("defaultconnection")5 {6 }7 8 PublicDbset<customers> Customer {Get;Set; }9 Ten PublicDbset<company> Company {Get;Set; } One}
Note: The name inside the base in the database context is the same as the name of the Webconfig link string
Entity Framework Link Database settings