ナゲット経由でMicrosoft.AspNetCore.Identity.EntityFrameworkCore
を追加しました。スタートアップ」の設定でPostgreSQLでIdentityを使用するには?
スタートアップ
public void ConfigureServices(IServiceCollection services)
{
//Add PostgreSQL support
services.AddEntityFrameworkNpgsql()
.AddDbContext<StoreDbContext>(options =>
options.UseNpgsql(Configuration["Data:StoreDbContext:ConnectionString"]));
// Add framework services.
services.AddMvc();
services.AddIdentity<PostgreApp.Models.User, IdentityRole>()
.AddEntityFrameworkStores<StoreDbContext>()
.AddDefaultTokenProviders();
// Add our PostgreSQL Repository
services.AddTransient<IStoreRepository, StoreRepository>();
}
私は、次の追加しました:
app.UseIdentity();
これは私のコードです:
public class StoreDbContext: IdentityDbContext<User>
{
public StoreDbContext(DbContextOptions<StoreDbContext> options) : base(options)
{
}
public DbSet<Store> Stores { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<Department> Departments { get; set; }
public DbSet<JobPost> JobPosts { get; set; }
public DbSet<Candidate> Candidates { get; set; }
public DbSet<CandidateCV> CandidateCVs { get; set; }
public DbSet<Criterion> Criteria { get; set; }
public DbSet<AssessmentStage> AssessmentStages { get; set; }
public DbSet<AssessmentCriterion> AssessmentCriteria { get; set; }
public DbSet<JobpostCv> JobpostCvs { get; set; }
}
それから私はこれを取得しています:
のSystem.InvalidOperationException:text型の列IDは、 ValueGenerated.OnAddを持っていますが、デフォルト値は Microsoft.EntityFrameworkCore.Migrations.NpgsqlMigrationsSqlGenerator.ColumnDefinition(文字列 スキーマ、文字列のテーブル、列名、タイプclrType、文字列型で定義されていませんMicrosoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.ColumnDefinitionで NULL可能
1 unicode, Nullable
1 maxLengthの、ブールrowVersion、ブール NULL可能、オブジェクトのデフォルト値は、文字列defaultValueSql、列 computedColumnSql、IAnnotatableの注釈可能、IModelをモデル、 MigrationCommandListBuilderビルダー) (AddColumnOperation 動作IModelモデル、MigrationCommandListBuilder b uilder)Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generateで (CreateTableOperation 操作、IModelをモデル、MigrationCommandListBuilderビルダーを、ブール は終了)Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generateで (CreateTableOperation 操作、IModelをモデル、MigrationCommandListBuilderビルダー) Microsoft.EntityFrameworkCore.MigrationsでMicrosoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 操作、IModelをモデル)でMicrosoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation 操作、IModelをモデル、MigrationCommandListBuilderビルダー) で .Internal.Mi Microsoft.EntityFrameworkCore.Design.MigrationsOperations.UpdateDatabaseでMicrosoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(文字列 targetMigration) (文字列 targetMigration、ストリングcontextType)Microsoft.EntityFrameworkCoreで でgrator.GenerateUpSql(移行 マイグレーション) .Tools.Cli.DatabaseUpdateCommand。 <> c__DisplayClass0_0.b__0()at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[]
引数)Microsoft.EntityFrameworkCore.Tools.Cli.Program.Mainで (文字列[]引数)型テキストの列IDがValueGenerated.OnAddを有するが、デフォルト 値はありません定義済み
どうすれば解決できますか?
を参照してください文字列の代わりにIdentityUserをimplementitn試すことができます。答えがわからない場合は、代わりにコメントを追加してください。 –
"Microsoft.EntityFrameworkCore": "1.1.2" –
があなたの提案を適用しました。まだ同じエラーです。私も自分のコードを更新しました。見てください –