ErikEJ / SqlCeToolbox

SQLite & SQL Server Compact Toolbox extension for Visual Studio, SSMS (and stand alone)
Other
843 stars 175 forks source link

LINQ to SQL, supported project types? #551

Closed hultqvist closed 6 years ago

hultqvist commented 6 years ago

I've made changes to a SQL Server Compact 4.0 database and now I want to update the generated DataContext.

I get this dialog: image

The project is a .NET Framework 4.6.1 and it is working fine with the previously generated code. Although I do have other project types in the same solution, most of them are .NET 4.6.1.

I've tried to "select" the project I want to target by opening other files, setting it as the start project(although it's a library)

I also tried to download the latest release from this repo but generating a LINQ to SQL DataContext gives this error. image

Steps to reproduce

Next I created a new .NET 4.6.1 Console application in a new solution. Tried to generate the DataContext: image image

Further technical details

Toolbox/Power Tools version: 4.7.406.0 Version 4.7.406.0 - 908 638 downloads

SQL Server Compact 4.0 in GAC - Yes - 4.0.8876.1 SQL Server Compact 4.0 DbProvider - Yes

SQL Server Compact 4.0 DDEX provider - No SQL Server Compact 4.0 Simple DDEX provider - Yes

SQL Server Compact 3.5 in GAC - Yes - 3.5.8080.0 SQL Server Compact 3.5 DbProvider - Yes

SQL Server Compact 3.5 DDEX provider - No

Sync Framework 2.1 SqlCe 3.5 provider - No

SQLite ADO.NET Provider included: 1.0.105.1 SQLite EF6 DbProvider in GAC - No System.Data.SQLite DDEX provider - No SQLite Simple DDEX provider - Yes

Database engine: SQL Compact

Visual Studio or SSMS version: Visual Studio 2017 15.4.2

reza-hm89 commented 6 years ago

I have same problem

ErikEJ commented 6 years ago

@hultqvist Pls share your csproj file! I will get the SQLMetal issue fixed asap - where is it located on your machine?

hultqvist commented 6 years ago

Here is the .csproj file of the newly created project.

How do I know where SQL Metal is, should I install it separately?

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{5088F829-E5BA-46FE-9CE4-EE0A9500BB3A}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>ConsoleApp3</RootNamespace>
    <AssemblyName>ConsoleApp3</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
ErikEJ commented 6 years ago

sqlmetal.exe is installed - look for it on your disk using file search!

I have attempted a fix in the latest daily build, could you please try that out:

https://github.com/ErikEJ/SqlCeToolbox/wiki/Release-notes

hultqvist commented 6 years ago

This is the path:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools

Now using your latest release:

Using the test csproj I posted earlier it works.

However using my real project it still complains with with error:

image

That project looks like it's using the newer, less verbose, project format:

<Project Sdk="Microsoft.NET.Sdk">
...
ErikEJ commented 6 years ago

Aaaah! Fixed in latest daily build

hultqvist commented 6 years ago

Any plans on supporting the new .csproj format?

ErikEJ commented 6 years ago

Does the latest daily build not work for you? 4.7.421

hultqvist commented 6 years ago

I'm now testing 4.7.422 and it's working. I must have downloaded the daily build too soon 2 days ago.

I noted that I no longer get the dialog where I choose tables to include. Now I get all tables. This includes __ExtendedProperties which gives a warning about missing Primary Keys. For me that's not a problem.

Thanks

ErikEJ commented 6 years ago

@hultqvist I have logged: #552 - that should be fixed, thanks for noticing

ErikEJ commented 6 years ago

@hultqvist I do not think that this feature ever supported selecting tables...

hultqvist commented 6 years ago

You're right, I was thinking of the "Script Schema..." which still works.

image