开发者

Entity Framework error - "Type argument 'Namespace...EntityName' does not satisfy the 'Class' constraint for the type 'TEntity'."

开发者 https://www.devze.com 2023-02-14 12:16 出处:网络
I have the following two tables defined... CREATE TABLE [LogLevel] ( [Id] int primary key ,[Name] nvarchar(50) not null

I have the following two tables defined...

CREATE TABLE [LogLevel] (
  [Id] int primary key
  ,[Name] nvarchar(50) not null
  ,[Enabled] bit not null default (0)
)
GO

CREATE TABLE [Log] (
  [Id] bigint identity(1,1) primary key
  ,[LogLevel] int not null fo开发者_如何学运维reign key references [LogLevel]([Id])
  ,[On] datetimeoffset not null default (SYSDATETIMEOFFSET())
  ,[Summary] nvarchar(100)
  ,[Details] nvarchar(MAX)
)

After creating a fresh endity model, I add the two tables above. When I try to build I get the following errors...

  • Type argument 'Inxsol.CommandPlan.Data.Model.Log.LogLevel' does not satisfy the 'Class' constraint for type parameter 'TEntity'.
  • Value of type 'System.Data.Objects.DataClasses.EntityReference(Of Inxsol.CommandPlan.Data.Model.LogLevel)' cannot be converted to 'System.Data.Objects.DataClasses.EntityReference(Of Inxsol.CommandPlan.Data.Model.Log.LogLevel)'.
  • Value of type 'System.Data.Objects.DataClasses.EntityReference(Of Inxsol.CommandPlan.Data.Model.Log.LogLevel)' cannot be converted to 'System.Data.Objects.DataClasses.EntityReference(Of Inxsol.CommandPlan.Data.Model.LogLevel)'.
  • Maximum number of errors has been exceeded.

  • Okay, hopefully someone else can post a better answer, but apparently the fit has something to do with the table [LogLevel]'s name or the table [Log]'s name... in either case, renaming them to [DiagnosticLog] and [DiagnosticLogLevel] resolved the issue at hand.

    0

    精彩评论

    暂无评论...
    验证码 换一张
    取 消