单独的类错误中的实体框架验证没有找到用于实现部分方法声明的定义声明

时间:2014-01-21 15:45:35

标签: c# entity-framework validation

这是我生成的类Customer

namespace Winpro
{
using System;
using System.Collections.Generic;

public partial class Customer
{
    public Customer()
    {
        this.Blocked = false;
        this.Code = "#00000";
        this.Contacts = new ObservableListSource<Contact>();
    }

    public int Id { get; set; }
    public string Name { get; set; }
    public string Code { get; set; }

    ...

ValidateCustomer类

namespace Winpro
{
public partial class Customer
{
    partial void OnCodeChanging(string value)
    {
        if (string.IsNullOrEmpty(value))
            throw new InvalidOperationException("value cannot be null or empty");
    }
}
}

解决方案有两个项目:

+ Database (model and validation) <-- here I'm creating ValidateCustomer class
+ Winpro   (winApp)

Error 1 No defining declaration found for implementing declaration of partial method 'Winpro.Customer.OnCodeChanging(string)' C:\Users\..\Projects\Winpro\Database\ValidateCustomer.cs 12 22 Database

我已经读过这是名称空间问题,但是从发布的代码中可以看出所有类都在同一名称空间中?

我该怎么做才能纠正这个错误。

我之前的问题,我从哪里获得此代码和解释:

Where to put functions and validation code Entity framework

0 个答案:

没有答案