首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> 關於.NET

NBearV3 VS Plugin 使用教程

     編輯:關於.NET

版本資訊

版本:1.3 [2007-04-24]

簡介

本教程介紹 NBearV3 中 Visual Studio 2005 代碼生成插件的使用方法。

學習目標

透過本教程,讀者應能全面掌握 NBearV3 VS2005 代碼生成插件的操作。

程式碼範例來源

教程演示的 EntityDesignToEntityConfig.xml 範例代碼,收錄於 NBearV3 最新原始碼套件中的 tutorials\VsPlugin_Tutorial 目錄,遇到疑問可直接參考。

預估時間

不超過 10 分鐘。


使用步驟

使用 NBear VS 插件僅需兩個步驟:

1. 安裝插件

雙擊 dist\SetupNBearVsPlugin.exe 即可完成安裝。

2. 建立設定檔

在實體設計專案的根目錄下建立名為 EntityDesignToEntityConfig.xml 的檔案,或直接複製 tutorials\VsPlugin_Tutorial 下的同名檔案並修改。

典型設定檔內容

<?xml version="1.0" encoding="utf-8" ?>
<EntityDesignToEntityConfiguration xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
  <CompileMode>Debug</CompileMode>
  <InputDllName>EntityDesigns.dll</InputDllName>
  <OutputNamespace>Entities</OutputNamespace>
  <OutputLanguage>C#</OutputLanguage>
  <!--<OutputCodeFileEncoding>utf-8</OutputCodeFileEncoding>-->
  <EntityCodePath>..\Entities\Entities.cs</EntityCodePath>
  <EntityConfigPath>..\website\EntityConfig.xml</EntityCodePath>
  <SqlSync enable="false">
    <SqlServerFolder>C:\Program Files\Microsoft SQL Server\80\Tools\Binn</SqlServerFolder>
    <ServerName>.</ServerName>
    <UserID>sa</UserID>
    <Password>sa</Password>
    <DatabaseName>tempdb</DatabaseName>
  </SqlSync>
</EntityDesignToEntityConfiguration>

設定項說明

  • CompileMode:指定讀取 DLL 所在的輸出目錄為 Debug 或 Release。
  • InputDllName:實體設計 DLL 的檔案名稱。
  • OutputNamespace:等同於 EntityDesignToEntity.exe 工具的 OutputNamespace 參數。
  • OutputLanguage:生成實體代碼的語言,可選 C# 或 VB.NET。
  • OutputCodeFileEncoding:生成代碼檔案的編碼,未指定則使用作業系統預設編碼。
  • EntityCodePath:生成的實體代碼檔案路徑。
  • EntityConfigPath:生成的實體配置 XML 檔案路徑。
  • SqlSync:設定是否自動同步資料庫表與視圖結構。各選項含義一目了然。

使用效果

打開 v3.3.7 及後續版本中 tutorials 目錄下的 ORM、IoC 等教程方案,編譯任意 EntityDesigns 專案。編譯成功後,Entities.cs、EntityConfig.xml 甚至相關資料庫表結構都會自動更新同步。原本需手動執行 EntityDesignToEntity.exe 生成同步的工作,現全由 VS Plugin 自動完成。

注意事項

  • 請修改所有教程中 EntityDesignToEntityConfig.xml 的 SqlSync 區段:SqlServerFolder、ServerName、UserID、Password,或暫時將 enable 設為 false。
  • SQL Server 2005 環境下,SqlServerFolder 通常應設為 X:\Program Files\Microsoft SQL Server\90\Tools\Binn。

本文結束

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved