0

Hi I'm using entity framework code first to create my database

[Range(1, 100)]
[DataType(DataType.Currency)]
public decimal Price { get; set; }

The problem is when the table is created the "Price" field takes up the data type decimal(18, 2) and if I tried to change the data type to money the SQL Server did not allowed me to do so.

Is there a way so that I may define a specific data type? That my sql server data type is assigned to money by default?

Or is there another way to solve this? I'm using .Net Framework 4. EF 4.4.0.0 on visual studio 2010 ultimate and MS SQL Server 2008 Express sp2.

4

1 に答える 1

1

これは、異なるSQLサーバーのデータ型を選択する部分の解決策です

[Column(“BlogDescription", TypeName="ntext")] 
public String Description {get;set;}

また、データベースで使用する別の列名を選択することもできます。ここで、エンティティの Description 列は、実際には MS SQL SERVER データ型 ntext のデータベース テーブルに BlogDescription 列として格納されます。

于 2013-05-28T13:50:58.150 に答える