nhibernate-从域对象创建数据库 [英] nhibernate - create db from domain object

查看:68
本文介绍了nhibernate-从域对象创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是新来的冬眠.我阅读了一篇文章,并据此尝试使用域对象创建数据库.

我的配置文件:

Hi,

I am new to nhibernate. I read an article and according to it I tried to create db with domain object.

My config file :

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=FADIK-TOSH\SQLEXPRESS;Database=DatabaseNHB;Trusted_Connection=True;</property>
    <!--<property name="connection.connection_string">Data Source=DatabaseNHB.mdf</property>-->
    <property name="show_sql">true</property>
    <!-- we want to see the SQL NHibernate generates and sends to the database (highly recommended for debugging purposes during development) -->
  </session-factory>
</hibernate-configuration>




我的sql服务器是默认的,因此没有sql服务器身份验证.我使用Windows身份验证登录.

但是我无法创建数据库.
错误是:登录请求"Cannot open database "DatabaseNHB".登录失败.
用户''fadik-TOSH\fadik的登录失败."




My sql server is default so there is no sql server authentication. I login with windows authentication.

But I can not create db.
the error is : "Cannot open database "DatabaseNHB" requested by the login. The login failed.
Login failed for user ''fadik-TOSH\fadik''."

What is wrong?

推荐答案

看起来您的基本连接字符串正确,唯一有问题的元素是"Database = DatabaseNHB".您需要验证(1)SQL Express服务器上是否存在名为"DatabaseNHB"的数据库,以及(2)已授予用户"fadik-TOSH \ fadik"访问权限.最好的检查方法是使用Windows身份验证使用Query Analyzer或SQL Server Management Studio登录,打开名为"DatabaseNHB"的数据库,并在该数据库中定义的任何表上运行选择.
It looks like you got your basic connection string right, and the only problematic element is "Database=DatabaseNHB". You need to verify that (1) the database called "DatabaseNHB" exists on your SQL Express server, and that (2) the user ''fadik-TOSH\fadik'' is granted access to it. The best way to check this is to log in with the Query Analyzer or SQL Server management studio using Windows Authentication, opening the database called "DatabaseNHB", and running a select on any table defined in that database.


这篇关于nhibernate-从域对象创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆