I am using EF5 with VS2012 and I ran into a problem while creating tables.
1) I create an easy database schema (edmx) that contains 2 tables:
- Table 1: Face
- Attribute: Id (Guid)
Attribute: name (string)
Table 2: Role
- Attribute: Id (Guid)
- Attribute: Type (string)
- Attribute: PersonId (Guid) (association with a table character)
2) that defines the properties of a unique key (called Id) as follows:
- Concurrency Mode: None
- Default value: None
- Entity Key: True
- Getter: Public
- Name: Id
- Nullable: False
- Setter: Normal
- StoreGeneratedPattern: Identity
- Type: Guid (I also tried with Int32)
3) And the properties of the Entity model are:
- Code Generation Strategy: None
- Database Generation Workflow: TablePerTypeStrategy (VS)
- Database Schema Name: dbo
- DDL generation pattern: SSDLToSQL10.tt (VS)
- Entity Container Access: Public
- Entity Container Name: DatabaseSchemaContainer
- Lazy Loading Enabled: True
- Metadata artifact processing: built into output assembly
- Namespace: DatabaseSchema
- Pluralize new objects: False
- Convert related text patterns to Save: True
- Refresh Facets Facility: True
- Validate On Build: True
4) related classes are created, but the [Key] attribute is missing:
using System; using System.Collections.Generic; public partial class Person { public Person() { this.Role = new HashSet<Role>(); }
5) I create a domain service to display the above objects to the client, for example:
[EnableClientAccess] public class DomainService1 : DomainService { [Query] public IEnumerable<Person> GetPersonSet() { } [Update] public void UpdatePerson(Person person) { } [Insert] public void InsertPerson(Person person) { } [Delete] public void DeletePerson(Person person) { } }
6) Recovering and receiving errors:
The "Person" object in the DomainService "DomainService1" does not have a specific key. Object types subject to DomainService actions must have at least one public property marked with KeyAttribute.
Any suggestion appreciated!
Ale
source share