Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:41:08+00:00 2026-06-11T12:41:08+00:00

I’m supporting an application in which we need to migrate the code first generated

  • 0

I’m supporting an application in which we need to migrate the code first generated database. The change is to modify three properties (all on the same table/entity) from a string to a nullable decimal.

Part of the requirement of doing this is that I need to output the changes to a SQL file, since we a deploying the patch to our client, who is also hosting the product in production.

I was told that this is possible but I am unsure how to do it.

Question: How can I, using EF code first, migrate the database table to have nullable decimals instead of strings and have the changes outputted to a SQL file. I am making the assumption that all the values currently in the column are convertible to decimals, but if not how would that change the complexity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:41:09+00:00Added an answer on June 11, 2026 at 12:41 pm

    If I’m correct in the requirements, then you’ll need to create a migration, then run

    Update-Database -Script
    

    This will create a sql script that will be run against the DB to update the structure.

    Also Update-Database -Verbose will update the DB structure, and output the SQL run.

    If you need to preserve the data, you can also run SQL in your migration script directly:

    public partial class RenameColumn : DbMigration
    {
        public override void Up()
        {
           Sql("update blah...");
        }
    
        public override void Down()
        {
          Sql("drop table bobby");
        }
    

    And there you can do whatever you need to do to preserve the data: add temp colum/table, copy original data there, change the column type, convert the data to a required format and copy it to the new column, clean-up.

    If you have Sql command in the migration, when you run Update-Database -Script, it will give you combined script – scaffolded migration script and your manually written script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.