Workflow for EF Core with Database Project

entity-framework-core sql-server visual-studio

Question

Feel free to tell me that this question needs to be moved and I will move it. I just don't know where else to go for help.

My current work flow is:

  1. Create the database first (database Actual)
  2. Run scaffold command which creates my models
  3. Create a Visual Studio Database project
  4. Import the database (database project)

Whenever I need to make a change to the database I follow the below:

  1. Change the database project
  2. Run a Schema Compare
  3. Verify and update the database Actual
  4. rerun the scaffold command with a -Force to rebuild all the models.

What (if any) type of problems am I leaving myself open to down the road?

I am not seeing the value of database migrations as I am updating the database first but using the database project to provide source control and some protection.

I always used to use the graphic database tool, but obviously with Core that is no longer an option.

I have also considered Devart's Entity Developer as a ORM.

Your thoughts and feedback are VERY much appreciated.

So the biggest problem is what happens when I need to make changes to the model.

So something simple like:

 public partial class UserInfo
{
    public int Id { get; set; }
    [Required]
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
    public DateTime RecordCreated { get; set; }
}

My '[Required]' will obliviously be gone after a -force.

Joe

1
1
12/1/2018 7:34:25 PM

Accepted Answer

That is the correct "database first" workflow for EF Core, and you would not use migrations in that scenario. Be sure to place customizations to your entities or DbContext in separate partial class files so they don't get clobbered when you regenerate the entities.

always used to use the graphic database tool, but obviously with Core that is no longer an option.

With this workflow you can use any graphical design tool you want for your database schema.

1
12/1/2018 7:11:30 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow