我正在使用带有EntityFramework的ASP.NET Web API Core 2.0连接到AWS MariaDB实例。
我也有一个具有完全相同模式的本地MariaDB实例。
当我通过本地连接运行Web API时,一切正常。
连接到AWS时,我得到表'xxxxx.AspNetUsers'不存在。 (xxxxx是数据库名称)
我什至在ApplicationDbContext中添加以下内容:
public class ApplicationDbContext : IdentityDbContext<AppUser>
{
public ApplicationDbContext(DbContextOptions options)
: base(options)
{
}
public DbSet<AppUser> AppUsers { get; set; }
public DbSet<Profile> Profiles { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<AppUser>().ToTable("aspnetusers");
builder.Entity<Profile>().ToTable("profiles");
base.OnModelCreating(builder);
}
}
对配置文件的注释api调用工作正常。
如何进行设置,以便EntityFramework不查找“ xxxxx.table”而是查找“ table”?还识别“ aspnetusers”
services
.AddDbContext<ApplicationDbContext>(
options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection")))
.AddUnitOfWork<ApplicationDbContext>();
编辑:
本地与AWS的连接字符串格式
服务器=本地主机;用户ID = root;密码= xxxxxxx;数据库= CoolAppDB
Server = coolappdb.1234564798.us-west-2.rds.amazonaws.com; Port = 3306; User ID = username; Password = xxxxxxx; Database = coolappdb