none
Is there a tutorial for creating SqlServer database code first RRS feed

  • Question

  • I've created the vb code from a database but I have a set of objects already defined in vb that I need to have created in Sqlserver.  Is there a tutorial showing how to accomplish this?


    Lloyd Sheen

    Monday, March 4, 2019 2:34 PM

All replies

  • Hello Lloyd,

    Do you mean Entity Framework code first from database or something else?


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, March 4, 2019 2:47 PM
    Moderator
  • Actually code first to database (in other words I have the objects defined in vb , need to create the corresponding tables in SqlServer.

    Lloyd Sheen

    Monday, March 4, 2019 2:48 PM
  • Actually code first to database (in other words I have the objects defined in vb , need to create the corresponding tables in SqlServer.

    Lloyd Sheen

    Then I would ask if you are okay with Entity Framework then and if so have you worked with Entity Framework? 

    Entity is fairly easy to generate tables but you need to take time to learn.

    Here is a decent starting page.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, March 4, 2019 3:27 PM
    Moderator
  • I have done lots of work using EF but I have always had the database first.  This work switches the work flow as I have all the object definitions not the table definitions.  (could do it manually but I know that there is a way to do it auto).

    Lloyd Sheen

    Monday, March 4, 2019 5:43 PM
  • I have done lots of work using EF but I have always had the database first.  This work switches the work flow as I have all the object definitions not the table definitions.  (could do it manually but I know that there is a way to do it auto).

    Lloyd Sheen

    So this means Code First Migrations which will create the database and tables from a model. Don't have any VB.NET articles to share, only C#. Note EF Core dropped migrations.

    https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/

    Personally my take is not to create database and tables from code but instead create the database in SSMS, get it setup properly then use a code generator such as this one which compiles "as you change the tt file). There is even a Pluralsight video on it.

    In the tt fil there are plenty of settings and explanations. 

    In summary I realize that I took a different direction than you wanted you can always look into migrations.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, March 4, 2019 6:04 PM
    Moderator