使用Entity Data Model 之創建模型(一)

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 即可。


待續......


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章