I'm using .NET 8, Visual Studio 2022, Clean Architecture, DDD, EF Core, postgresql.
I have these 4 layers: Infrastructure, Application, Domain, Presentation
I have defined my entities in the domain layer. Let's call them A, B and C.
I have created configurations in the infrastructure layer inheriting from IEntityTypeConfiguration<TEntity>
.
I can build and add a migration successfully in my infrastructure layer.
Here is my concern:
I'm connecting to an existing Postgresql database with an existing table that my application is built around to read from. I have defined the content of the existing table as an entity (A) in my domain layer.
How can I create new tables wit my other entities (B and C) while Entity Framework understands that A has an existing table that I only want to read from?
Please ask for further details if I have not expressed myself clearly.
Thank you!
My first migrations seems to want to create a new table
migrationBuilder.CreateTable(
name: "TransferMessages",
columns: table => new
How do I point to the existing table so it knows that it is there?
I would go this way:
Entity A
and your DbSet<A>
.Up()
and Down()
methods in your
initial migration.dotnet-ef
tool.Entities B and C
with DbSet<B>
and DbSet<C>
.dotnet-ef
tool again.Now you have 3 Tables in the database and everything should work now.