I've extended my ASP.Net Web Pages application with the Entity Framework, which I have downloaded in Visual Studio via NuGet. Now I get the following error, while trying to assign a different column name to a propertie.
CS0246: The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?)
My Model:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
using WebMatrix.Data;
namespace Models {
public class News
{
public int Id { get; set; }
[Column("d_date")]
public DateTime Date { get; set; }
[Column("m_text")]
public string Text { get; set; }
}
}
The ColumnAttribute
should be in System.ComponentModel.DataAnnotations.Schema
, so I can't understand the problem.
UPDATE My Web.Config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="MyDatasource" connectionString="server=localhost; database=testdb; User Id=***; Password=***;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>