首先使用数据库自​​定义身份 table

Customizing Identity table with database first

正在尝试构建使用 ASP.NET 身份验证的应用程序。

我一直在观看有关如何做事的 video。他们将新属性直接添加到 ApplicationUser class,然后使用代码优先迁移更新数据库。

但我首先使用数据库。

所以我将我的新属性直接添加到 ApplicationUser class,并且我还向我的数据库添加了兼容字段。但是我还是报错了。

The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

我用 Google 搜索了这篇文章,找到了专门引用 数据库优先 的文章,但它们似乎都涉及使用 代码优先!

这甚至可以不用代码先做吗?还是我们都将首先使用代码或死去?

正如@Kyle 所建议的,这都是基于 __MigrationHistory table。

我不确定这一切究竟是如何工作的,或者如果每次我 运行 我的软件都根据我的数据测试这个 table 时的开销是多少。但是重命名 table 可以消除错误。我现在可以按照我的意愿修改数据库而不会出错。