locked
Enitity Framework Database first design RRS feed

  • Question

  • Hello,

    I'm using database first approach of Entity Framework.

    I have a varchar(255) column in database. I want to resize the column to varchar(512).

    As we know the varchar datatype maps to string without considering the column size, i want to know do we have to update Edmx file. 


    Wednesday, November 16, 2016 7:30 AM

Answers

  • Hi,

    The varchar and nvarchar are mapped to string when you right click in the model and check the properties of the filed in the mapping you will find the length of the char. but if you want to resize it and it is database first then you can just go to your database and change the you column to length of 512 and the update the model by right click and update model. or after chance the size in the database then change the length in properties manually.

    I hope this is helpful.


    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid

    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development

    MyBlog

    • Proposed as answer by Naomi N Wednesday, November 16, 2016 11:23 AM
    • Marked as answer by Kalman Toth Monday, December 19, 2016 3:49 PM
    Wednesday, November 16, 2016 7:52 AM
  • You may eventually find this tool very helpful for your case:

    https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator

    We're using it in our project. You don't have to support EDMX, all changes in your database are reflected immediately in the models once you re-save your tt file. It is very easy to use and there is a Pluralsight course by the author of this tool.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    • Marked as answer by Kalman Toth Monday, December 19, 2016 3:49 PM
    Wednesday, November 16, 2016 11:26 AM

All replies

  • Hi,

    The varchar and nvarchar are mapped to string when you right click in the model and check the properties of the filed in the mapping you will find the length of the char. but if you want to resize it and it is database first then you can just go to your database and change the you column to length of 512 and the update the model by right click and update model. or after chance the size in the database then change the length in properties manually.

    I hope this is helpful.


    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid

    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development

    MyBlog

    • Proposed as answer by Naomi N Wednesday, November 16, 2016 11:23 AM
    • Marked as answer by Kalman Toth Monday, December 19, 2016 3:49 PM
    Wednesday, November 16, 2016 7:52 AM
  • You may eventually find this tool very helpful for your case:

    https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator

    We're using it in our project. You don't have to support EDMX, all changes in your database are reflected immediately in the models once you re-save your tt file. It is very easy to use and there is a Pluralsight course by the author of this tool.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    • Marked as answer by Kalman Toth Monday, December 19, 2016 3:49 PM
    Wednesday, November 16, 2016 11:26 AM