Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Dropping Columns referenced by other Tables

Dropping Columns referenced by other Tables

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasehelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simpledeveloper
    wrote on last edited by
    #1

    Hi I have 3 Tables Cases, Programs, Violations, now all these Tables are related as ManyToMany with Notice Table, but earlier they were having OneToMany, but now they are related ManyToMany, hence I moved them all to the Associated Table to handle it, which is called as ManyToMany table which has PK, ParentyEntity, ParentEntityId (which is PK of Notices table), ChildEntity, ChildEntityId - I have to do it with Entity Framework Code First Migrations - hence I am trying to be very cautious here. What am I planning are 1.Take backup of the Database 2. Migrate Data from tables to ManyToMany table 3. Record all the Foreign Key Constraints first (like generate scripts for those FKs references) then drop all those Foreign Keys 4. Then Drop tables using Entity Framework Code First Migrations. Can somebody please help me if I am missing anything and are there any easy fool proof ways to do the same and how to drop columns using Entity Framework Migrations - I have lost touch with Code First approach, I understand its tough and needed very careful implementation - any suggestion any help would be very very helpful. Actually the Database has already have been implementing this - but they didn't drop the old columns and didn't delete the data from old columns - hence its creating or showing inconsistent Data, the old programmer has left it in between - need a lot of suggestions and support - thanks a lot.

    L 1 Reply Last reply
    0
    • S simpledeveloper

      Hi I have 3 Tables Cases, Programs, Violations, now all these Tables are related as ManyToMany with Notice Table, but earlier they were having OneToMany, but now they are related ManyToMany, hence I moved them all to the Associated Table to handle it, which is called as ManyToMany table which has PK, ParentyEntity, ParentEntityId (which is PK of Notices table), ChildEntity, ChildEntityId - I have to do it with Entity Framework Code First Migrations - hence I am trying to be very cautious here. What am I planning are 1.Take backup of the Database 2. Migrate Data from tables to ManyToMany table 3. Record all the Foreign Key Constraints first (like generate scripts for those FKs references) then drop all those Foreign Keys 4. Then Drop tables using Entity Framework Code First Migrations. Can somebody please help me if I am missing anything and are there any easy fool proof ways to do the same and how to drop columns using Entity Framework Migrations - I have lost touch with Code First approach, I understand its tough and needed very careful implementation - any suggestion any help would be very very helpful. Actually the Database has already have been implementing this - but they didn't drop the old columns and didn't delete the data from old columns - hence its creating or showing inconsistent Data, the old programmer has left it in between - need a lot of suggestions and support - thanks a lot.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      "Code First" is "easy"; it's hard when you're thinking about "conversion" when still developing a data model. The final model drives the conversion process ("ETL"); not the other way around.

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      S 2 Replies Last reply
      0
      • L Lost User

        "Code First" is "easy"; it's hard when you're thinking about "conversion" when still developing a data model. The final model drives the conversion process ("ETL"); not the other way around.

        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

        S Offline
        S Offline
        simpledeveloper
        wrote on last edited by
        #3

        Can you please elaborate a little bit buddy?

        Gerry Schmitz wrote:

        "Code First" is "easy";

        I understood that

        Gerry Schmitz wrote:

        it's hard when you're thinking about "conversion"

        Which conversion?

        Gerry Schmitz wrote:

        when still developing a data model

        The Data model is already developed, I am maintaining the application, I am scared if I drop the column from Code, it will drop that column permanently from Database and how am I going to migrate the data? I think I will have to write my own scripts for it, am I correct my friend? Any detailed suggestions or links anything helps my friend - but even for this I thank you for taking your time to answer my queries - its a great help.

        Gerry Schmitz wrote:

        The final model drives the conversion process ("ETL"); not the other way around

        I didn't really get this, means ETL should migrate the Data how? - thank you my friend.

        1 Reply Last reply
        0
        • L Lost User

          "Code First" is "easy"; it's hard when you're thinking about "conversion" when still developing a data model. The final model drives the conversion process ("ETL"); not the other way around.

          It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

          S Offline
          S Offline
          simpledeveloper
          wrote on last edited by
          #4

          Hi, unfortunately I have deleted the tables that are created by entity framework Code first migration file manually, now when i am running the migrations or add migration file, its throwing error when running the Update-Database command. What can I do for it now? Can you please help me in this regards buddy? I have the copy of the Deleted migration file, but its not running its giving compile error if I try to run. Can I delete all those tables that are created by running the previous migration file, clean it up and create new fresh migration file and run update database - any-help would be very very helpful. Another problem I tried to run the migration file previous to that of deleted migration file to restore to previous stage - since it could delete the records - that's also not running - any help please to make again fresh start by deleting the newly created tables and create new migration file and run update database.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups