My question is quite simple, and I searched many times for an answer, but could not find a solution. However, this does not seem like an unusual scenario, so if I miss something simple or there is a link that I missed, this concerns my problem, I would be grateful for some guidance! Here goes ...
When trying to connect to an existing database outside of my new .Net Core project. I followed the reverse engineering instructions here: https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html
These instructions work for db on my local computer, but when I run Scaffold-DbContext with the DNS connection string for the database for the external server, it creates a context, but not entities. So my context class file is as follows:
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace CensusApi.Models
{
public partial class CensusDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
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.
}
}
The ErrorList window refers to #warning on line 11 of the above code (i.e., a warning to protect potentially confidential information in the connection string). I understand the next step after this reverse engineering is to reinstall the connection string, and that #warning is a general warning and not an obstacle to the reverse engineering process.
The credentials I tried include the sa user as well as the limited user. Both have the same results, so they are not a permission issue.
, ?
!