aspnetboilerplate - How to use a varchar column other than Id column using ASP.NET Boilerplate? -


i have table has code pk, below exception in createeditions method of aspnet-core\src\nec.stanchion.entityframeworkcore\migrations\seed\host\defaulteditioncreator.csonce try run application.

[table("test")] public class test: fullauditedentity<string> {      [databasegenerated(databasegeneratedoption.identity)]     new public int id { get; set; }     [key]     [databasegenerated(databasegeneratedoption.none)]     [maxlength(nvarcharlength14), datatype(datatype.text)]     public virtual string code { get; set; } 

declared repository:

private readonly irepository<article, string> _articlerepository; 

exception:

system.invalidoperationexception: 'the specified field '<id>k__backingfield' of type 'int' cannot used property 'article.id' of type 'string'. backing fields of types assignable property type can used.' 

i'm getting same error while running update-database , add-migration.

the specified field '<id>k__backingfield' of type 'int' cannot used property 'article.id' of type 'string'. backing fields of types assignable property type can used. 

do mean use varchar type primary key? declare entity class this:

public class article: entity<string> {   //you should comment line   //[databasegenerated(databasegeneratedoption.identity)]   //new public int id { get; set; } } 

then can use repository:

private readonly irepository<article, string> _articlerepository; 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -