简体   繁体   English

首先在远程安全数据库上使用EF和数据库

[英]Using EF with database first on a remote and secured database

I am wondering if it's possible to use Entity Framework to scan a database and build an EDMX model in the following scenario: 我想知道在以下场景中是否可以使用Entity Framework扫描数据库并构建EDMX模型:

(It's actually a PostgreSQL database and I'll probably use dotConnect , but I assume the principle is the same, and I'm asking a similar question on the devart forums.) (它实际上是一个PostgreSQL数据库,我可能会使用dotConnect ,但我认为原理是一样的,我在devart论坛上问了一个类似的问题。)

The database is secured with SSL and the administrator has provisioned access for a single IP address - the address of the machine that hosts my ASP.NET website. 该数据库采用SSL安全管理员配置的单个IP地址的访问-承载我的ASP.NET网站的计算机的地址。

Will it be theoretically possible to set up Visual Studio (on my dev machine) and the host machine in such a way that I'll be able to access this database with my dev machine? 理论上可以设置Visual Studio(在我的开发机器上)和主机,这样我就能用我的开发机器访问这个数据库吗? What will I need to set up on the host machine to allow it to be used as a proxy (I have full admin access to it)? 我需要在主机上设置什么才能将其用作代理(我有完全的管理员访问权限)?

Without having tried anything, it seems like the only option is to install Visual Studio on the host machine, build the EDMX model there, and import it into my dev environment and create the actual database locally, but I only want to do this as a last resort. 没有尝试任何东西,似乎唯一的选择是在主机上安装Visual Studio,在那里构建EDMX模型,并将其导入我的开发环境并在本地创建实际数据库,但我只想这样做最后一招。

Just copy postgres tools and libraries to server machine (or install full postgres DB on it) and use pg_dump to dump DB schema and/or data to a file. 只需将postgres工具和库复制到服务器计算机(或在其上安装完整的postgres DB),并使用pg_dump将DB模式和/或数据转储到文件中。

Read this page for the details about pg_dump . 有关pg_dump的详细信息,请阅读this page

If you want schema only dump use --schema_only key for pg_dump . 如果您只想使用模式转储,请使用--schema_only键作为pg_dump

dotConnect for PostgreSQL allows you to connect through a proxy. dotConnect for PostgreSQL允许您通过代理连接。 You can install a proxy server on a computer, which hosts your ASP.NET website and has access to the PostgreSQL database. 您可以在计算机上安装代理服务器,该计算机承载您的ASP.NET网站并可以访问PostgreSQL数据库。 You can connect to a database via this proxy server. 您可以通过此代理服务器连接到数据库。 For this you need to apply the following connection settings: 为此,您需要应用以下连接设置:

PgSqlConnection conn = new PgSqlConnection("host=<DATABASE HOST>;port=5434;uid=<USER ID>;pwd=<PASSWORD>");
conn.ProxyOptions.Host = "PROXY HOST";
conn.ProxyOptions.Port = 3128;
conn.ProxyOptions.User = "PROXY USER ID";
conn.ProxyOptions.Password = "PROXY PASSWORD";

dotConnect for PostgreSQL also can connect via SSL. dotConnect for PostgreSQL也可以通过SSL连接。 For this you need to configure your server so that it supports SSL connections and apply the following connection settings: 为此,您需要配置服务器以使其支持SSL连接并应用以下连接设置:

conn.SslOptions.CACert = "D:\\Certificates Pg\\client\\root.crt";
conn.SslOptions.Cert = "D:\\Certificates Pg\\client\\client.crt";
conn.SslOptions.Key = "D:\\Certificates Pg\\client\\client.key";
conn.SslOptions.SslMode = SslMode.Require;

dotConnect for PostgreSQL allows creating SSL connection via proxy. dotConnect for PostgreSQL允许通过代理创建SSL连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM