I dont know I am asking stupid question if so please sorry
I just created model into the existing context. Is it possible to create a new table in to the existing database using that new model in context , without running migrate entire object
Not 100% clear. With EF you have basically two approach ie :
- "code first" : you are writing C# describing db entities and EF creates/updates the database for you
- "code first from database", "scaffolding" : you start from the database and EF generates the corresponding C# code for you
Or finally you take the whole control and both update the db and the code yourself if you really want. For now it's unclear if you have a problem with your current approach and you wan't to switch?
Edit: or do you mean you want to create a table inside your database without exposing it through EF ?
I dont know I am asking stupid question if so please sorry
I just created model into the existing context. Is it possible to create a new table in to the existing database using that new model in context , without running migrate entire object
please can you let me know.
Yeah that's how migrations work!!! The process finds the changes since the last migration and created migration file. If you made changes other than the new model/table and don't want those changes in the DB then you are not using the technology correctly.
Is it possible to create a new table in to the existing database using that new model in context , without running migrate entire object
If you want to create a table, you can manually use sql sentence to create it in SQL Server Object Explorer.
The migrations feature in EF Core provides a way to incrementally update the database schema to keep it in sync with the application's data model while preserving existing data in the database.
If you want to use it in your project,use add-migration at least in either code first or database first
approach will be better.
Best Regards,
Jerry Cai
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
410 Points
1326 Posts
How to create a table in to the existing database using EF
Sep 18, 2020 11:55 AM|polachan|LINK
I dont know I am asking stupid question if so please sorry
I just created model into the existing context. Is it possible to create a new table in to the existing database using that new model in context , without running migrate entire object
please can you let me know.
Pol
All-Star
48490 Points
18070 Posts
Re: How to create a table in to the existing database using EF
Sep 18, 2020 12:10 PM|PatriceSc|LINK
Hi,
Not 100% clear. With EF you have basically two approach ie :
- "code first" : you are writing C# describing db entities and EF creates/updates the database for you
- "code first from database", "scaffolding" : you start from the database and EF generates the corresponding C# code for you
Or finally you take the whole control and both update the db and the code yourself if you really want. For now it's unclear if you have a problem with your current approach and you wan't to switch?
Edit: or do you mean you want to create a table inside your database without exposing it through EF ?
Edit 2: if new to EF Core start maybe with https://docs.microsoft.com/en-us/ef/core/managing-schemas/
Contributor
4923 Points
4198 Posts
Re: How to create a table in to the existing database using EF
Sep 18, 2020 12:11 PM|DA924|LINK
Why can't you use SSMS and create the table via the DBA tool?
All-Star
52971 Points
23571 Posts
Re: How to create a table in to the existing database using EF
Sep 18, 2020 12:21 PM|mgebhard|LINK
Yeah that's how migrations work!!! The process finds the changes since the last migration and created migration file. If you made changes other than the new model/table and don't want those changes in the DB then you are not using the technology correctly.
Participant
940 Points
312 Posts
Re: How to create a table in to the existing database using EF
Sep 21, 2020 02:53 AM|Jerry Cai|LINK
Hi,polachan
If you want to create a table, you can manually use sql sentence to create it in SQL Server Object Explorer.
The migrations feature in EF Core provides a way to incrementally update the database schema to keep it in sync with the application's data model while preserving existing data in the database.
If you want to use it in your project,use add-migration at least in either code first or database first approach will be better.
Best Regards,
Jerry Cai