Want to create this table on application start if it does not exist.
Code:
public class Database : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var db = applicationContext.DatabaseContext.Database;
//Cant add this table due to the ENUM
if (!db.TableExist("FormData"))
{
db.CreateTable<FormData>(false);
}
}
}
Model:
[PrimaryKey("Id")]
public class FormData
{
[PrimaryKeyColumn(AutoIncrement = true, IdentitySeed = 1)]
public int Id { get; set; }
[NullSetting(NullSetting = NullSettings.NotNull)]
public FormType Type { get; set; }
[NullSetting(NullSetting = NullSettings.NotNull)]
public string Data { get; set; }
[NullSetting(NullSetting = NullSettings.NotNull)]
public DateTime Date { get; set; }
}
Error message:
[InvalidOperationException: Sequence contains no matching element] System.Linq.Enumerable.First(IEnumerable
1 source, Func
2 predicate) +415 Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase1.FormatType(ColumnDefinition column) +1225 Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase
1.Format(ColumnDefinition column) +155 Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase1.Format(IEnumerable
1 columns) +144 Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase`1.Format(TableDefinition table) +131 Umbraco.Core.Persistence.PetaPocoExtensions.CreateTable(Database db, Boolean overwrite, Type modelType) +161 Umbraco.Core.Persistence.PetaPocoExtensions.CreateTable(Database db, Boolean overwrite) +121
Looking at the error I dont think there is a solution to this without updating the core but here is to hoping you guys can help