小编use*_*543的帖子

EF中的问题,映射片段,没有默认值,不可为空

我正在开发MVC 3 Applicaiton.

我有模特第一个approch.

我有公司实体(摘要).Lead和Customer继承自公司实体.

当我试图验证模型时,它给出了错误.

错误41错误3023:从第70行开始映射片段时出现问题:表Companies.Status表必须映射公司:它没有默认值且不可为空.

这是表的映射.

在此输入图像描述

这是HTML视图中的EDMX代码.

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
    <Schema Namespace="Model1.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator">
    <EntityContainer Name="Model1StoreContainer">

        <EntitySet Name="Companies" EntityType="Model1.Store.Companies" store:Type="Tables" Schema="dbo" />

    </EntityContainer>

    <EntityType Name="Companies">
        <Key>
            <PropertyRef Name="Id" />
        </Key>
        <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
        <Property Name="Name" Type="nvarchar(max)" Nullable="false" />
        <Property Name="Status" Type="nvarchar(max)" Nullable="false" />
        <Property Name="__Disc__" Type="nvarchar" MaxLength="Max" Nullable="false" />
    </EntityType>
</Schema></edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" …
Run Code Online (Sandbox Code Playgroud)

entity-relationship entity-framework entity-framework-4 entity-framework-4.1

3
推荐指数
1
解决办法
8770
查看次数