Closed cetindogu closed 2 years ago
The Pull Request for "Support Multiple Key Types for Base Entity" approved and merged. But same error on latest code.
@cetindogu what error do you see?
On runtime, error is tables "Requires a primary key"
After i set database column name to same as entity class attribute name, no primary key error
And also i cant use directly reverse poco generator(ef core power tools) İ will create a TT file to generate all entity classes, similar ti youra
Your block entity probably doesn't have an Id property that's named according to the convention (the convention is that a field calld Id
, or <entityName>Id
is regarded as the primary key).
Otherwise, can you show us the definition of the block entity?
Primary key problem gone after renamed ID to Id Entity class attribute name and database column names must match
İ need reverse poco generator, possible temproary solutions 1) Via source generators 2) Via T4 file
Isn't that included in ef power tools? A bit off topic anyways for this repo...
After generation With ef core power tools, İt needs some other changes 1) our applicationDBcontext .cs must be partial 2) for New context, you have to set the namespaces same With our applicationdbcontext.cs 3) ef core power tools doesnot set the base class So i manually changed the New context inheritance : DbContext inheritance to : IBaseDbContext for compability With our applicationDBcontext.cs 4) ef core power tools entity types doesnot have "Update" method
İ need time to check more and more
I think you should only generate the entities, not the dbcontext... add the dbsets manually to the existing ApplicationDbContext and you're set, right?
The update method is just that... a manually added method on the entity.. you can surely just add that after the entities are generated? This is just one way of mapping dto's to entities btw... there are other ways to do that if you don't want to use an "Update" method...
I think you should only generate the entities, not the dbcontext... add the dbsets manually to the existing ApplicationDbContext and you're set, right?
The update method is just that... a manually added method on the entity.. you can surely just add that after the entities are generated? This is just one way of mapping dto's to entities btw... there are other ways to do that if you don't want to use an "Update" method...
Okey i will try Again later. İ didnt want to modify any boilerplate files, to pull latest code changes immediately, so i use partial keyword to change boilerplate files
İ got it, just entity generation is enought No need to generate DbContext file
now, i want to use "fullstackhero/dotnet-webapi-boilerplate" for my new project
so, is there any easy way to generate entity classes from an existing database
I also
But,
Unhandled exception
System.InvalidOperationException: The entity type 'BLOCK' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943.
i also need
172 - Support Multiple Key Types for Base Entity #256
https://github.com/fullstackhero/dotnet-webapi-boilerplate/pull/256