I’ve got a WCF service using EF (still learning it) to store some own metadata in a database. At some point i realized(requirements changed) I don’t need separate entities for some classes and would like to convert them to Complex Types since relationship is 1:1. I don’t mind recreating database or losing any data since there’s none.
The problem is that whenever I try to run the app or call Update-database I get “The type ‘Model.ReportConfig’ has already been configured as an entity type. It cannot be reconfigured as a complex type.” Which somehow makes sense but I don’t really want it to be re-configured, but configured from a scratch but even though I removed all the old tables and even specified absolutely clean database in web.config I still get this error.
Btw. I don’t see any EdmMetadata table.
This is confusing care about my data integrity. Any ideas?
EDIT ReportConfig in question. No other configuration in my DbContext (even though I tried adding modelBuilder.ComplexType(); in OnModelCreating)
[DataContract]
[ComplexType]
// [Table("UserReportConfigs", Schema = "WebApp")]
public class ReportConfig
{
// [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
// public long Id { get; set; }
[DataMember]
public string Title { get; set; }
[DataMember]
public DateTime From { get; set; }
[DataMember]
public DateTime To { get; set; }
[DataMember]
public int ReportAs { get; set; }
[DataMember]
public string ParamValue { get; set; }
}
EDIT2 I renamed the ReportConfig to Configuration and the error message reflects new name now, so my assumption that it’s metadata trying to keep up is probably wrong. Looks like during migration EF registers it as entity and then finds out that it’s marked as ComplexType.
I’m using 5.0.0-rc version of EF
Make sure you don’t still have a
DbSet<ReportConfig>in your DbContext class, as this would be telling EF thatReportConfigis an entity.