Hi Guys,
I hope you are all well and that someone here might be able to shed some light on my issue.
I have a database table with the following setup:
ID [Bigint]<br />
Name [nvarchar(250)]<br />
ISOCode [nvarchar(5)]<br />
MarketType [tinyint]
Using EntityFramework 6 Database first, I have added this table to my edmx file and it generates a class called "Market".
Off of this, I have created two classes, 'SingleMarket' and 'CombinedMarket' (Some of you may be thinking da-ja-vu here but this is different to my last question relating to the same objects).
I have converted the Type property on my Market to be an Enum which has two options:
Single = 1,<br />
Combined = 2
These determine whether an object is a Single or Combined market, as I'm sure you gathered by now.
My issue is that right now my edmx fails so build with the error
"Default Values are allowed only for non-spatial primitive types"
Now I know that this error is caused by my "MarketType" property on the market base class, but I want the MarketType to default to 1 (Single). I also want to keep the "MarketType" property on my entity.
If I delete the MarketType property then it all compiles, but then I can't say "What type is this Market", or if I can I don't know how to.
I also have this error:
"
Problem in mapping fragments starting at lines 290, 298, 304:Column Market.MarketType has no default value and is not nullable. A column value is required to store entity data.<br />
An Entity with Key (PK) will not round-trip when:<br />
( PK is in 'Markets' EntitySet AND Entity is type [MRPData.Market])
"
So, in simple, how can I keep my "MarketType" property on the base class and have it set with a default value of 1 (single) ?
Any questions/clarification needed please ask.
Thanks in advance.
[Edit]Type property renamed to MarketType as per Dave's advice.[/Edit]