1. 添加實體數據模型的方法:
右擊 --> Add --> New Item --> ADO.NET Entity Data Model --> Add --> Generate from database --> Next --> New Connection... -->選擇 Yes, include... --> Next
--> 選table,view, stored procedures... --> Finish 即可。生成類似如下數據模型:
2. web.config 裏會增加如下設置:
<configuration>
......
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
......
</configuration>
build solution, successful 即可。
待續......