zoukankan      html  css  js  c++  java
  • NBearV3——VsPlugin使用教程

    版本

    1.3 [2007-4-24]

    简介

    本教程介绍NBearV3中的VS2005代码生成插件的使用。

    目标

    通过本教程,读者应能够全面掌握NBearV3中的VS2005代码生成插件的使用。

    代码

    本教程演示的EntityDesignToEntityConfig.xml文件示例代码,包含于可以从http://nbear.org下载的NBearV3最新源码zip包中的tutorials\VsPlugin_Tutorial目录中。因此,在使用本教程的过程中如有任何疑问,可以直接参考这些代码。

    时间

    <10分钟。

    正文

    要使用NBearVs插件,只需要执行两个步骤:

    首先,需要安装NBearVs插件。只需要双击dist\SetupNBearVsPlugin.exe文件,就能完成安装。

    接着,在实体设计工程的项目根目录中,创建一个名为EntityDesignToEntityConfig.xml的文件。也可以直接复制tutorials\VsPlugin_Tutorial下的EntityDesignToEntityConfig.xml文件,再进行必要的修改。

    典型的EntityDesignToEntityConfig.xml文件内容如下:

    <?xml version="1.0" encoding="utf-8" ?>
    <EntityDesignToEntityConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://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</EntityConfigPath>
     
    <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所在的output目录是Debug还是Release

    InputDllName表示实体设计dll的名称。

    OutputNamespace等价于EntityDesignToEntity.exe工具的OutputNamespace

    OutputLanguage为生成的Entities的语言,可选的值为C#或VB.NET

    OutputCodeFileEncoding为生成到EntityCodePath指定的代码文件的encoding,如果不指定则为操作系统的默认编码

    EntityCodePath表示生成的具体的实体代码所在的代码文件。

    EntityConfigPath表示生成的实体配置代码所在的xml文件。

    SqlSync中的内容设置了,是否需要及如何连接数据库,从而在设计实体有变化时,自动同步数据库中的表和视图。各选项应该无需过多解释,大家一看就能明白。

    使用效果

    要体验VsPlugin插件的强大功能,大家只需打开v3.3.7及以后版本中的tutorials目录中的ORM和IoC等教程的sln,编译任意的EntityDesigns工程,您将注意到,在EntityDesigns工程成功编译之后,Entities.cs和EntityConfig.xml代码,甚至相关的数据库表示图结构就自动更新同步了。所有这些过程原来都需要用户手工使用EntityDesignToEntity.exe工具来生成同步,现在,所有的一切,都可以由VsPlugin帮你来做。

    注意

    请注意修改所有教程中的EntityDesignToEntityConfig.xml中的SqlSync中的SqlServerFolder的值和相应的ServerName,UserID和Password。或者可以暂时将SqlSync的enable设为false。

    对于SqlServer2005,一般SqlServerFolder的值应该设为X:\Program Files\Microsoft SQL Server\90\Tools\Binn。

    //本文结束

  • 相关阅读:
    P1019 单词接龙
    P1219 八皇后
    Find a way
    P1056 排座椅
    P1067 多项式输出
    关于前缀和,A
    洛谷P1223
    洛谷P1803
    洛谷P1208
    常用方法 Excel转换为DataSet
  • 原文地址:https://www.cnblogs.com/teddyma/p/580075.html
Copyright © 2011-2022 走看看