ASP.Net Identity - Use custom Schema(ASP.Net Identity - 使用自定义架构)
问题描述
我首先在 ASP.Net Identity 1.0 中使用 MVC5 + Ef6 代码,并希望在自定义模式中创建表.即不是 dbo 架构的架构.
I am using MVC5 + Ef6 code first with ASP.Net Identity 1.0 and wish to have the tables created in a custom schema. i.e. a schema that is not the dbo schema.
我使用 Ef 电动工具对我的数据库进行逆向工程,并将映射类中所有其他表的模式名称设置为以下
I reversed engineered my databse using the Ef power tools and set the schema name for all other tables in the mapping class to the following
this.ToTable("tableName", "schemaName");
我尝试为 ASP.Net 表执行此操作,但它不断给我很多错误,最终我放弃了.如果我从我的项目中排除(逆向工程)ASP.Net Identity 表,它们将被创建但始终在 dbo 架构中
I tried doing this for the ASP.Net tables but it kept giving me a lots of errors and eventually I gave up. If I exclude the (reverse engineered) ASP.Net Identity tables from my project they will be created but always in the dbo schema
有人知道怎么做吗?
推荐答案
public class MyDbContext : EntityDbContext<ApplicationUser>
{
public DbSet<ApplicationUser> Users { get; set; }
public MyDbContext() : base()
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// You can globally assign schema here
modelBuilder.HasDefaultSchema("schemaName");
}
}
这篇关于ASP.Net Identity - 使用自定义架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ASP.Net Identity - 使用自定义架构


基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01