ColumnExists, AddColumn Extensions
See original GitHub issueI would like to do this:
//Create Database:
if(!db.TableExists<MyEntity>())
{
db.CreateTable<MyEntity>(); //Right now I have to try catch that...
}
//Updating db:
//These can ether be on ITable<MyEntity> or db itself
if(!Entities.ColumnExists(e => e.NewProperty))
{
Entities.AddColumn(e => e.NewProperty);
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Best practices using SUMMARIZE and ADDCOLUMNS
Extension columns are columns that you add to existing tables. You can obtain extension columns by using both ADDCOLUMNS and SUMMARIZE.
Read more >c# - EF migrations Code First. Add column to database if ...
I have worked on creating a custom migration method, AddColumnIfNotExists. You need a custom MigrationOperation class:
Read more >How can I add column to an existed sqlite database?
Currently the new version of my program needs to add a column to the database for a new feature. The program is made...
Read more >Writing Migrations - 0.13
Columns are added using the addColumn() method. We create a unique index for both the username and email columns using the addIndex() method ......
Read more >Add Column to List Content Type using PowerShell
Select the appropriate column group and then select the column you want to add to the content type, click on the “Add” button,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SlowLogicBoy @frankhaugen
You can create your own extension method to replicate CreateTableIfNotExists as such:
You can add additional parameters to pass through to
CreateTable()
as needed, or switch toCreateTableAsync()
.NB: above is for SQL Server only. Adjust for your preferred db.
You can create the following extension probably in separate static class:
You can use as reference
DataConnectionExtensions.BulkCopy