Build Errors: 'DataContractAttribute' could not be found

Posts   
 
    
hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 18-Dec-2018 17:28:02   

Am I missing something when I create a new project? I get the following errors when I build from Visual Studio.

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?)

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'DataContract' could not be found (are you missing a using directive or an assembly reference?)

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'IsReference' could not be found (are you missing a using directive or an assembly reference?)

Also using System.Collections.Generic; is greyed out

Attachments
Filename File size Added on Approval
12-18-2018 11-22-59 AM.png 78,950 18-Dec-2018 17:28.17 Approved
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Dec-2018 20:28:16   

Those Attributes are generated by default. Someone has to specify them in the Project Settings (Entity Model / Code Generation).

Please check the project settings and remove them if you don't want them.

hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 18-Dec-2018 21:45:56   

I removed all the Attributes in the settings.

But when I build the project in VS it says its missing Microsoft.EntityFrameworkCore. So I add it via NuGet - Install-Package Microsoft.EntityFrameworkCore -Version 2.1.0 to match the Entity Model.

Now I get

Severity Code Description Project File Line Suppression State Error CS1061 'ModelBuilder' does not contain a definition for 'HasDefaultSchema' and no accessible extension method 'HasDefaultSchema' accepting a first argument of type 'ModelBuilder' could be found (are you missing a using directive or an assembly reference?) Test.DAL.Persistence

Severity Code Description Project File Line Suppression State Error CS1061 'EntityTypeBuilder<ImportFreezer>' does not contain a definition for 'ToTable' and no accessible extension method 'ToTable' accepting a first argument of type 'EntityTypeBuilder<ImportFreezer>' could be found (are you missing a using directive or an assembly reference?) Test.DAL.Persistence

Severity Code Description Project File Line Suppression State Error CS1061 'PropertyBuilder<int>' does not contain a definition for 'HasColumnName' and no accessible extension method 'HasColumnName' accepting a first argument of type 'PropertyBuilder<int>' could be found (are you missing a using directive or an assembly reference?) Test.DAL.Persistence

What am I going wrong?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 19-Dec-2018 12:36:01   

the DataContract attributes are present in a project which targets Entity Framework 6. If you use that target framework, you have to reference the assembly which contains them (System.Runtime.Serialization) or remove them.

If you want to target the Entity Framework Core framework, as I think you want to considering the fact you're referencing that in your code, you have to target that framework in the llblgen pro project. Right-click the node in project explorer which says "Entity Framework 6" and select 'Switch target framework' and select "Entity Framework Core 2.1".

Frans Bouma | Lead developer LLBLGen Pro
hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 26-Dec-2018 20:00:05   

I did that and cleared out all the Attributes. Now I get this? I created a TypedView. public partial class TvImportLocationTypedViewRow : CommonTypedViewRowBase

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'CommonTypedViewRowBase' could not be found (are you missing a using directive or an assembly reference?) CORELims.DAL.Model C:\Users\mark.perry.AMER\Source\Repos\CoreLIMSWebPortal\CORE.DAL\Model\TypedViewClasses\TvImportLocationTypedViewRow.cs 9 Active

I remove that and still get build errors. My project is .Net Core 2.1. Does that matter? It also seems to be missing the EF when I build it so I have to add it to the DAL project?

Severity Code Description Project File Line Suppression State Error CS1061 'ModelBuilder' does not contain a definition for 'HasDefaultSchema' and no accessible extension method 'HasDefaultSchema' accepting a first argument of type 'ModelBuilder' could be found (are you missing a using directive or an assembly reference?) CORELims.DAL.Persistence C:\Users\mark.perry.AMER\Source\Repos\CoreLIMSWebPortal\CORELims.DAL\Persistence\CORELimsDALModelBuilder.cs 20 Active Error CS1061 'EntityTypeBuilder<ImportFreezer>' does not contain a definition for 'ToTable' and no accessible extension method 'ToTable' accepting a first argument of type 'EntityTypeBuilder<ImportFreezer>' could be found (are you missing a using directive or an assembly reference?) CORELims.DAL.Persistence C:\Users\mark.perry.AMER\Source\Repos\CoreLIMSWebPortal\CORELims.DAL\Persistence\CORELimsDALModelBuilder.cs 34 Active Error CS1061 'PropertyBuilder<int>' does not contain a definition for 'HasColumnName' and no accessible extension method 'HasColumnName' accepting a first argument of type 'PropertyBuilder<int>' could be found (are you missing a using directive or an assembly reference?) CORELims.DAL.Persistence C:\Users\mark.perry.AMER\Source\Repos\CoreLIMSWebPortal\CORELims.DAL\Persistence\CORELimsDALModelBuilder.cs 36 Active Error CS1061 'PropertyBuilder<int>' does not contain a definition for 'HasColumnName' and no accessible extension method 'HasColumnName' accepting a first argument of type 'PropertyBuilder<int>' could be found (are you missing a using directive or an assembly reference?) CORELims.DAL.Persistence C:\Users\mark.perry.AMER\Source\Repos\CoreLIMSWebPortal\CORELims.DAL\Persistence\CORELimsDALModelBuilder.cs 37 Active

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 27-Dec-2018 07:40:36   

If you want to target the Entity Framework Core framework, as I think you want to considering the fact you're referencing that in your code, you have to target that framework in the llblgen pro project. Right-click the node in project explorer which says "Entity Framework 6" and select 'Switch target framework' and select "Entity Framework Core 2.1".

I wrote this above, did you look into that? .NET Core 2.1 requires EF Core 2.1+ and you seem to have chosen Entity Framework 6 (as that's adding attributes to the entities).

Your csproj files therefore aren't properly setup too. Please first(!) make sure your llblgen pro project uses EF Core 2.1 (see quoted paragraph above). Then generate into a new, empty folder.

Frans Bouma | Lead developer LLBLGen Pro
hankddog
User
Posts: 52
Joined: 08-Apr-2005
# Posted on: 28-Dec-2018 16:19:58   

I did set the Target Framework to Core v 2.1. So I created a new project with one table in it.

Ran it, and it the created Persistence project, it had all the errors.

Here is what my settings look like.

Attachments
Filename File size Added on Approval
llblissue.png 30,949 28-Dec-2018 16:20.15 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 29-Dec-2018 10:05:51   

You're generating code for .NET 4.6.1 (see your screenshot top right corner). If you want to target .net core 2.1, you have to select .net core 2.1 there.

As you already have csproj files, please generate into an empty folder to get a new codebase for the generated code including new csproj files which have the new vs project format and are for .net core 2.1. They have ef core package references setup so when you add those to your solution (and remove the old ones you have), vs should pull ef core properly from nuget.

Frans Bouma | Lead developer LLBLGen Pro