This question is locked. New answers and comments are not allowed.
I am using OpenAccess.CodeFirst and OpenAccess.CodeFirst.Sample version 2012.2.924.1 via NuGet, just modified the product with a datetime property like following
and mapping to auto/default mapping
but the generated schema does not have datetime column
I was surprised as i have used the version 2012.1.427.1 package in past, it creates schema correctly.
also if i use the explicit mapping like following
i get the desired results,
I would like to use the default/auto mapping as some of my other classes have more fields in a time management related project.
Regards
public
class
Product
{
public
int
ID {
get
;
set
; }
public
string
ProductName {
get
;
set
; }
public
DateTime CreateDate {
get
;
set
; }
public
decimal
Price {
get
;
set
; }
}
and mapping to auto/default mapping
MappingConfiguration<Product> productConfiguration =
new
MappingConfiguration<Product>();
productConfiguration.MapType().ToTable(
"Products"
);
productConfiguration.HasProperty(x => x.ID).IsIdentity(KeyGenerator.Autoinc);
but the generated schema does not have datetime column
-- OrmTest.Product
CREATE
TABLE
[Products] (
[ID]
int
IDENTITY
NOT
NULL
,
-- <ID>k__BackingField
[Price]
numeric
(20,10)
NOT
NULL
,
-- <Price>k__BackingField
[ProductName]
varchar
(255)
NULL
,
-- <ProductName>k__BackingField
CONSTRAINT
[pk_Products]
PRIMARY
KEY
([ID])
)
go
I was surprised as i have used the version 2012.1.427.1 package in past, it creates schema correctly.
also if i use the explicit mapping like following
MappingConfiguration<Product> productConfiguration =
new
MappingConfiguration<Product>();
productConfiguration.MapType(x =>
new
{
ID = x.ID,
Price = x.Price,
CreatedDate = x.CreateDate,
ProductName = x.ProductName
}).ToTable(
"Products"
);
productConfiguration.HasProperty(x => x.ID).IsIdentity(KeyGenerator.Autoinc);
i get the desired results,
-- OrmTest.Product
CREATE
TABLE
[Products] (
[ID]
int
IDENTITY
NOT
NULL
,
-- <ID>k__BackingField
[Price]
numeric
(20,10)
NOT
NULL
,
-- <Price>k__BackingField
[CreatedDate] datetime
NOT
NULL
,
-- <CreateDate>k__BackingField
[ProductName]
varchar
(255)
NULL
,
-- <ProductName>k__BackingField
CONSTRAINT
[pk_Products]
PRIMARY
KEY
([ID])
)
go
I would like to use the default/auto mapping as some of my other classes have more fields in a time management related project.
Regards