我的问题很简单,我已经搜索了很多答案但是没有找到解决方案。然而,这似乎并不罕见,所以如果我忽略了一些简单的东西或者有一个我忽略了的参考可以解决我的问题,我将非常感激您的指导!以下是我的问题:
在尝试通过我的新.Net Core项目连接到现有的远程数据库时,我按照此处的反向工程化说明进行操作:https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html 这些说明适用于我的本地机器上的数据库,但是当我使用连接到远程服务器的数据库DNS运行Scaffold-DbContext时,它会创建上下文但没有实体。因此,我的上下文类文件看起来像这样:
错误列表窗口指的是上面代码中第11行的#warning(即保护连接字符串中有潜在敏感信息的警告)。我意识到在进行逆向工程之后的下一步是重新定位连接字符串,而#warning似乎是一种通用警告而不是对逆向工程过程的阻碍。
我尝试使用的凭据包括sa用户和受限制的用户。两者都有相同的结果,所以这似乎不是权限问题。
对于连接到外部服务器,是否有不同的方法或框架可供使用?
如有任何想法或反馈,非常感谢!
在尝试通过我的新.Net Core项目连接到现有的远程数据库时,我按照此处的反向工程化说明进行操作:https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html 这些说明适用于我的本地机器上的数据库,但是当我使用连接到远程服务器的数据库DNS运行Scaffold-DbContext时,它会创建上下文但没有实体。因此,我的上下文类文件看起来像这样:
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace CensusApi.Models
{
public partial class CensusDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseSqlServer(@"Server=database.dns.org,[port];Database=mydatabase;Integrated Security=False;User ID=myuser;Password=mypassword;");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
// Unable to generate entity type for table 'dbo.LANDING_DEMOGRAPHICS_2010'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.LANDING_ECONOMIC_2007_2011'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.LANDING_STATE_FIPS'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.LANDING_ZIP_STATE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.SAMAIN_ZIP_STATE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_HOUSEHOLDS'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_HOUSING_OCCUPANCY'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_MEDIAN_AGE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_MEDIAN_INCOME'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_POPULATION'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_POPULATION_BY_RANGE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_RACE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_RACE_HISPANIC_AND_LATINO'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_RELATIONSHIP'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.STAGE_ZIP_STATE'. Please see the warning messages.
// Unable to generate entity type for table 'dbo.LogShipStatus'. Please see the warning messages.
}
}
错误列表窗口指的是上面代码中第11行的#warning(即保护连接字符串中有潜在敏感信息的警告)。我意识到在进行逆向工程之后的下一步是重新定位连接字符串,而#warning似乎是一种通用警告而不是对逆向工程过程的阻碍。
我尝试使用的凭据包括sa用户和受限制的用户。两者都有相同的结果,所以这似乎不是权限问题。
对于连接到外部服务器,是否有不同的方法或框架可供使用?
如有任何想法或反馈,非常感谢!