Sorry for the delay, had to get some work done first.
The error types are:
<div>6 each in the same file:</div> <div>Severity Code Description Project File Line Suppression State</div> <div>Error CS0246 The type or namespace name 'BTEntities11' could not be found (are you missing a using directive or an assembly reference?) </div>
<div></div> <div>1 each:</div> <div> <div>Severity Code Description Project File Line Suppression State</div> <div>Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:</div> <div>System.IO.FileNotFoundException:
Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'.</div> <div>File name: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'</div>
<div> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)</div> <div> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,
SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)</div> <div> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)</div> <div> at Roslyn.Utilities.FileUtilities.OpenFileStream(String
path)</div> <div> at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String
x)</div> <div> at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()</div> <div> at System.Linq.Enumerable.d__67`1.MoveNext()</div> <div> at System.Linq.Enumerable.d__67`1.MoveNext()</div> <div> at System.Linq.Buffer`1..ctor(IEnumerable`1
source)</div> <div> at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)</div> <div> at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)</div> <div> at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1
items)</div> <div> at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1
newReferences)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()</div> <div> at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String
source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions) 1</div> </div> <div></div> <div>387 each for various tables:</div> <div> <div>Severity Code Description Project File Line Suppression State</div>
<div>Error CS1061 'ProviderSvcTransaction' does not contain a definition for 'ProviderService' and no accessible extension method 'ProviderService' accepting a first argument of type 'ProviderSvcTransaction' could be found (are you missing a using directive
or an assembly reference?) </div> </div> <div></div> <div></div>
Click on "Mark as Answer" if my answers help you along.
Error CS0246 The type or namespace name 'BTEntities11' could not be found (are you missing a using directive or an assembly reference?)
wavemaster
System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll
You'll need to make sure that you are referencing the Entity Framework reference files within your Project under References.
You can do that through the following steps:
Right-click your Project in the Solutions Explorer.
Choose Manage NuGet Packages...
Search for the EntityFramework Package.
Click Install to add it to your existing project
You can also refer to below links about similar error:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Error CS0246 The type or namespace name 'BTEntities11' could not be found (are you missing a using directive or an assembly reference?)
Can you show me what 'BTEntities11' is in your project?
wavemaster
System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'.
Are you sure that there is EntityFramework in your vs2019?
Best regards,
sam
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Core.Objects;
using System.Linq;
public partial class BTEntities11 : DbContext
{
public BTEntities11()
: base("name=BTEntities11")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Appointment> Appointments { get; set; }
public virtual DbSet<Associate> Associates { get; set; }
... plus 100 more of these to cover all the tables in the db
In Model.edmx:
EntityContainer Name="BTEntities11" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Appointments" EntityType="Self.Appointment" />
<EntitySet Name="Associates" EntityType="Self.Associate" />
... all the other tables are here as well
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Contributor
2611 Points
2711 Posts
VS2019 vs VS2017 and EF 6.0 - big mess
Oct 31, 2019 04:00 PM|wavemaster|LINK
2X Community Edition for visual studio
My application builds fine in VS2017, no errors.
Close the solution and now open it in VS2019. Add two non primary key column in one table.
After "Update model from database", Save and Build: I have 400 errors all related to dbContext and missing customizations on a few tables.
Close the solution and reopen in VS2017, then I do not see any error messages.
How is this possible?
All-Star
48510 Points
18071 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Oct 31, 2019 04:12 PM|PatriceSc|LINK
Hi,
And the most frequent error message is ?
Contributor
2611 Points
2711 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 01, 2019 08:30 PM|wavemaster|LINK
Sorry for the delay, had to get some work done first.
The error types are:
<div>6 each in the same file:</div> <div>Severity Code Description Project File Line Suppression State</div> <div>Error CS0246 The type or namespace name 'BTEntities11' could not be found (are you missing a using directive or an assembly reference?) </div> <div></div> <div>1 each:</div> <div> <div>Severity Code Description Project File Line Suppression State</div> <div>Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:</div> <div>System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'.</div> <div>File name: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'</div> <div> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)</div> <div> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)</div> <div> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)</div> <div> at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)</div> <div> at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)</div> <div> at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()</div> <div> at System.Linq.Enumerable.d__67`1.MoveNext()</div> <div> at System.Linq.Enumerable.d__67`1.MoveNext()</div> <div> at System.Linq.Buffer`1..ctor(IEnumerable`1 source)</div> <div> at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)</div> <div> at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)</div> <div> at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)</div> <div> at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()</div> <div> at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions) 1</div> </div> <div></div> <div>387 each for various tables:</div> <div> <div>Severity Code Description Project File Line Suppression State</div> <div>Error CS1061 'ProviderSvcTransaction' does not contain a definition for 'ProviderService' and no accessible extension method 'ProviderService' accepting a first argument of type 'ProviderSvcTransaction' could be found (are you missing a using directive or an assembly reference?) </div> </div> <div></div> <div></div>Contributor
3370 Points
1409 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 04, 2019 03:04 AM|samwu|LINK
Hi wavemaster,
You'll need to make sure that you are referencing the Entity Framework reference files within your Project under References.
You can do that through the following steps:
You can also refer to below links about similar error:
https://stackoverflow.com/questions/5741109/the-type-or-namespace-name-dbcontext-could-not-be-found
https://forums.asp.net/t/1892907.aspx?The+type+or+namespace+name+DbContext+could+not+be+found
Best regards,
Sam
Contributor
2611 Points
2711 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 04, 2019 11:40 AM|wavemaster|LINK
Keep in mind that this solution works in VS2017, not in VS2019
NPM has EntityFramework by Microsoft listed in the installed category with version 6.1.3, there is an update to version 6.3.0 available.
Contributor
3370 Points
1409 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 05, 2019 09:23 AM|samwu|LINK
Hi Wavemaster,
Can you show me what 'BTEntities11' is in your project?
Are you sure that there is EntityFramework in your vs2019?
Best regards,
sam
Contributor
2611 Points
2711 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 05, 2019 12:00 PM|wavemaster|LINK
In Model.Context.cs I have this:
In Model.edmx:
In web.config:
There are no squiggles when this solution is open in VS2019 CE, AFTER I have built and saved the project.
Nuget Package Manager says EF 6.1.3 is installed.
Is there another way to verify it is installed?
EDIT:
Now VS2019 shows a different message:
<div>Severity Code Description Project File Line Suppression State</div> <div>Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:</div> <div>System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'.</div> <div>File name: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\$(VSAPPIDDIR)EntityFramework.dll'</div> <div> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)</div> <div> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)</div> <div> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)</div> <div> at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)</div> <div> at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)</div> <div> at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()</div> <div> at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()</div> <div> at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()</div> <div> at System.Linq.Buffer`1..ctor(IEnumerable`1 source)</div> <div> at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)</div> <div> at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)</div> <div> at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)</div> <div> at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)</div> <div> at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()</div> <div> at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()</div> <div> at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions) 1 </div>Searching for EntityFramework.dll in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\
it finds 2 each:
one in the IDE folder
one in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Runtimes\5.0.0
Then the question becomes why does "update model from database look at: $(VSAPPIDDIR)EntityFramework.dll
What does that mean $(VSAPPIDDIR)?
Contributor
3370 Points
1409 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Nov 06, 2019 10:21 AM|samwu|LINK
Hi wavemaster,
Open the References in your project. To see if there is EntitFramework, if it is, you have already installed it.
The $(VSAPPDIR) is a variable when the project is run.
There are similar questions here, you can use as a reference.
https://developercommunity.visualstudio.com/content/problem/580524/after-update-to-1610-entityframework-code-generati.html
Best regards,
sam
Contributor
2611 Points
2711 Posts
Re: VS2019 vs VS2017 and EF 6.0 - big mess
Dec 31, 2019 02:35 PM|wavemaster|LINK
There is an issue with EF on the non preview versions of VS2019.
Someone at Microsoft suggested that I use the preview version which I did. Now EF can again create Model.edmx without any issues.
https://developercommunity.visualstudio.com/content/problem/806218/update-model-from-database-fails-in-vs2019-not-in.html?childToView=809981#comment-809981