DbLinq之各数据库生成脚本

本文详细介绍了DbMetal命令的使用方法,包括其主要功能、参数解释以及具体实例演示,帮助开发者快速掌握如何利用DbMetal进行数据库到代码的映射。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DbMetal [OPTIONS] [<DBML INPUT FILE>]

  Generates code and mapping for DbLinq. SqlMetal can:
  - Generate source code and mapping attributes or a mapping file from a database.
  - Generate an intermediate dbml file for customization from the database.
  - Generate code and mapping attributes or mapping file from a dbml file.

  -c, --conn=CONNECTION STRING
                             Database CONNECTION STRING. Cannot be used with
                               /server, /user or /password options.
  -u, --user=NAME            Login user NAME.
  -p, --password=PASSWORD    Login PASSWORD.
  -s, --server=NAME          Database server NAME.
  -d, --database=NAME        Database catalog NAME on server.
      --provider=PROVIDER    Specify PROVIDER. May be Ingres, MySql, Oracle,
                               OracleODP, PostgreSql or Sqlite.
      --with-schema-loader=TYPE
                             ISchemaLoader implementation TYPE.
      --with-dbconnection=TYPE
                             IDbConnection implementation TYPE.
      --with-sql-dialect=TYPE
                             IVendor implementation TYPE.
      --code=FILE            Output as source code to FILE. Cannot be used
                               with /dbml option.
      --dbml=FILE            Output as dbml to FILE. Cannot be used with /map
                               option.
      --language=NAME        Language NAME for source code: C#, C#2 or VB
                               (default: derived from extension on code file
                               name).
      --aliases=FILE         Use mapping FILE.
      --schema               Generate schema in code files (default: enabled).
      --namespace=NAME       Namespace NAME of generated code (default: no
                               namespace).
      --entitybase=TYPE      Base TYPE of entity classes in the generated
                               code (default: entities have no base class).
      --member-attribute=ATTRIBUTE
                             ATTRIBUTE for entity members in the generated
                               code, can be specified multiple times.
      --generate-type=TYPE   Generate only the TYPE selected, can be
                               specified multiple times and does not prevent
                               references from being generated (default:
                               generate a DataContex subclass and all the
                               entities in the schema).
      --generate-equals-hash Generates overrides for Equals() and
                               GetHashCode() methods.
      --sprocs               Extract stored procedures.
      --pluralize            Automatically pluralize or singularize class and
                               member names using specified culture rules.
      --culture=CULTURE      Specify CULTURE for word recognition and
                               pluralization (default: "en").
      --case=STYLE           Transform names with the indicated STYLE
                               (default: net; may be: leave, pascal, camel,
                               net).
      --generate-timestamps  Generate timestampes in the generated code
                               (default: enabled).
      --readline             Wait for a key to be pressed after processing.
      --debug                Enables additional information to help with
                               debugging, such as full stack traces in error
                               messages.
  -h, -?, --help             Show this help

 ***********************以上是帮助*********************************

 //MsSql------------------------

dbmetal --provider="SqlServer" --conn="Data Source=.;Initial Catalog=lzqlhxhjd;User Id=sa;Password=11111111" --namespace="PadServ.DBProvider" --code="LinqMssql.cs"
@pause

 

//MySql----------------------------------

dbmetal -provider="MySql" -conn="Data Source=localhost;port=6607;User Id=root;Password=" -database="xdb" -namespace="XHManageTool" -code="LinqMysql.cs" -sprocs
@pause

 

//Oracle------------------------------------

dbmetal -provider="Oracle" -conn="Data Source=ORCL;User Id=620104;Password=620104" -database="620104" -namespace="Rincere.DataBase" -code="DataBaseOracleLinq.cs" -sprocs
@pause

 

//Sqlite----------------------------------------------

dbmetal -provider="Sqlite" -conn="Data Source=xodb.slite;" -namespace="XHManageTool" -code="LinqSqlite.cs" -sprocs
@pause

 

 

说明:只需要保存为批处理文件,修改其中的数据库连接配置后放在dblinq的构造文件夹下运行即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值