Examples of EF5 Table Per Type that I have found, such as this one use the [Table("tablename")]
attribute to mark a class as defining a table.
When I add this attribute I get errors:
Error 1 The type or namespace name 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\EShared\Syrius6\syrius_syrius\SBD.Syrius.DomainClasses\Classes.cs 599 6 DomainClasses
Error 2 The type or namespace name 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\EShared\Syrius6\syrius_syrius\SBD.Syrius.DomainClasses\Classes.cs 599 6 DomainClasses
I have the line
using System.ComponentModel.DataAnnotations;
in my namespace
And I am using framework 4 because I want the app to run on Windows XP.
[Update] I had a look at the link flagged as a possible duplicate here, and as a consequence added a reference to System.Data.Linq and a using System.Data.Linq
The error messages are now
Error 1 The type or namespace name 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\EShared\Syrius6\syrius_syrius\SBD.Syrius.DomainClasses\Classes.cs 599 6 DomainClasses
Error 2 Using the generic type 'System.Data.Linq.Table<TEntity>' requires 1 type arguments E:\EShared\Syrius6\syrius_syrius\SBD.Syrius.DomainClasses\Classes.cs 599 6 DomainClasses
Importantly, I want my code to work on Windows XP , and the second answer to the possible duplicate requires framework 4.5
[Update] Code is as follows;
namespace SBD.Syrius.DomainClasses
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Linq;
[Table("Product")]
public class Product : LoggedEntity
{
[Required]
public string BuyUnitMeasure { get; set; }
[Required]
public Decimal BuyUnitQuantity { get; set; }
[Required]
public String Code { get; set; }
[Required]
public string Name { get; set; }
[Required]
public String SellUnitMeasure { get; set; }
[Required]
public Decimal SellUnitQuantity { get; set; }
public virtual Template Template { get; set; }
[Required]
public string UnitMeasure { get; set; }
public override string ToString()
{
return !string.IsNullOrEmpty(this.Name) ? this.Name : "Products";
}
}
public abstract class LoggedEntity
{
public int Id { get; set; }
public Guid RowId { get; set; }
[ConcurrencyCheck]
public int RowVersionId { get; set; }
public int SourceSiteNumber { get; set; }
}
}
[Update]
I corrected the using to be using System.Data.Linq.Mapping;
Now my error is
System.Data.Linq.Mapping.TableAttribute' does not contain a constructor that takes 1 arguments
[Update]
I also looked at the not accepted answer to the suggested duplicate question. Which is to use System.ComponentModel.DataAnnotations however this requires framework 4.5 and I don't think I can use that because it wont run on Windows XP, and I need to run on XP.
[update]
I am developing on Windows 7 but the application needs to run on XP. I see the example I am trying to follow Here it is again uses Framework 4.1 Fluent
My question is Can I use TPT on EF5 to run on Windows XP? If so, how?