Ask Your Question
4

Is it possible to generate the ADO.NET Entity Framework in C# while preserving the manually added tables?

asked 2021-10-06 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-10-05 19:00:00 +0000

djk gravatar image

Yes, it is possible to generate the ADO.NET Entity Framework in C# while preserving the manually added tables. There are two approaches to achieve this:

  1. Use "Code First" Approach: In this approach, you can create C# classes for your manually added tables and map them to the database using attributes or Fluent API. Then you can use the "Code First" tool in the Entity Framework to generate the database schema based on the model you created. This way, the manually added tables will be preserved.

  2. Use "Database First" Approach: In this approach, you can create a database schema with your manually added tables and then use the "Database First" tool in the Entity Framework to generate the corresponding C# classes based on the schema. This way, the manually added tables will also be preserved.

In both approaches, you need to make sure that the manually added tables are not overwritten or modified during the generation process. To do this, you can use annotations or naming conventions to ensure that the Entity Framework doesn't generate duplicate tables or modify existing ones.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-06 11:00:00 +0000

Seen: 18 times

Last updated: Oct 05 '22