EF DB first generates errors when Add Code Generation Items - c#

I'm trying to run the Code Generation for my edmx, however every time I do this, I'm being faced with lots of errors.
This is the Context.cs file is generated:
//------------------------------------------------------------------------------
/ <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace project.DAL
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class NebulabEntities : DbContext
{
public NebulabEntities()
: base("name=NebulabEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Commodity> Commodities { get; set; }
public virtual DbSet<CommoditiesPrice> CommoditiesPrices { get; set; }
}
}
The Errors I'm getting:
Severity Code Description Project File Line
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 13
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 14
Error CS0246 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 16
Error CS0115 'NebulabEntities.OnModelCreating(DbModelBuilder)': no suitable method found to override project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbSet<Commodity>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 28
Error CS0246 The type or namespace name 'DbSet<CommoditiesPrice>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 29
I'm using Visual Studio 2015 for this, and I've added EF to my class library project.
Does anyone know why it's generating code with errors?

This is because you are referencing older entity framework dll in your project. The solution is -
1. First remove the reference of older EF dll from Reference Manager.
2. Then add the Newer EF dll by using the browser feature.
For EF 6.1.3 you will get the dll in the folder "EntityFramework.6.1.3\lib\net45"

Related

Unity gives strange errors when i try to build my project

Unity gives me these strange errors for some reason when i try to build my project. I do not know why it gives me these errors, when they should've been given earlier. I've tried restarting unity, deleting the "plugins" folder, deleting the .sln files and putting the build folder on a different folder. How can i fix these strange errors??
here's the code unity keeps giving me errors from, if that helps anything: https://paste.myst.rs/lwj5nsm1
And here's the errors unity gave me:
Assets\LevelGenerator\Scripts\Editor\LevelEditor.cs(9,30): error CS0115: 'GeneratorEditor.OnInspectorGUI()': no suitable method found to override
Assets\LevelGenerator\Scripts\Editor\LevelEditor.cs(7,48): error CS0234: The type or namespace name 'Editor' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
Assets\LevelGenerator\Scripts\Editor\LevelEditor.cs(6,6): error CS0246: The type or namespace name 'CustomEditorAttribute' could not be found (are you missing a using directive or an assembly reference?)
Assets\LevelGenerator\Scripts\Editor\LevelEditor.cs(6,6): error CS0246: The type or namespace name 'CustomEditor' could not be found (are you missing a using directive or an assembly reference?)
UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in :0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in :0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Your code is used for the editor, and therefore should not be included in the build result.What I do to solve this, I create a "DONOTCOMPILETHIS" build directive that I add to the player Settings.
PlayerSetting DLG
and finaly in your code add :
using UnityEngine;
#if !DONOTCOMPILETHIS
using UnityEditor;
using UnityEditor.IMGUI.Controls;
[CustomEditor(typeof(CGameTower)), CanEditMultipleObjects]
public class CBoundRectEditor : Editor
{
private BoxBoundsHandle m_BoundsHandle = new BoxBoundsHandle();
...
}
#endif

USQL - Custom Outputter failed to find NewtonSoft

I have a USQL Job which reads json from Azure Blob and after some data manipulation writes a single line JSON file to ADLS.
I have written a Custom Ouputter to write JSON File.
This is how my CustomOutputter files look like:
using Microsoft.Analytics.Interfaces;
using Microsoft.Analytics.Types.Sql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
namespace demo{
[SqlUserDefinedOutputter(AtomicFileProcessing = true)]
public class JSONOutputter : IOutputter
{
//Actual Code Here
public static class Factory
{
public static JSONOutputter JSONOutputter(bool isHeader = true, Encoding encoding = null)
{
return new JSONOutputter(isHeader, encoding);
}
}
}
I am using this Ouputter in my USQL Job like this:
OUTPUT #final_output
TO "/output/json/final.json"
USING demo.Factory.JSONOutputter(isHeader: true);
When I compile my USQL Script using
ADL: Compile Script
I get this error:
[Info] Start compiling code behind: /users/kumar.pratik/documents/usql/second.usql.cs ...
[Error] Command failed: mono /Users/kumar.pratik/.vscode/extensions/usqlextpublisher.usql-vscode-ext-0.2.11/compilehost/compilehost.exe /users/kumar.pratik/documents/usql/second.usql.cs /Users/kumar.pratik/Documents/usql/usqlCodeBehindReference /Users/kumar.pratik/Documents/usql/second.usql.dll __codeBehind__tRYGlFBeSWcl
[Error] Compile failed
error: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" at line: 8, column 6
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 17, column 12
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 44, column 34
Could someone please let me know how can I get this fixed?
I am working on Visual Studio Code on Mac OS
Thanks
Can you please share how your script looks like? In particular, are you
Using Visual Studio's code behind for your Outputter code?
If the answer to 1 is no: Did you register your Outputter and Newtonsoft lib in the U-SQL catalog with CREATE ASSEMBLY or via the Visual Studio Assembly registration feature? And did you reference the U-SQL assemblies (both your own code and Newtonsoft) in your script with REFERENCE ASSEMBLY?
More details: https://blogs.msdn.microsoft.com/azuredatalake/2016/08/26/how-to-register-u-sql-assemblies-in-your-u-sql-catalog/

How to create a dll for one class that reference other dlls in c# asp.net?

I have this following class I am trying to make a dll from
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NRules.Fluent.Dsl;
using NRule.site.Model;
using NRule.site.Utilities;
namespace NRule.site.Rules
{
public class AllowAtleastOneCountryRule : Rule
{
public override void Define()
{
FundProfile productProfile = null;
string str = RuleTexts.AllowAtleastOneCountryRule;
bool enabled = AllRules.GetDict()[str];
When()
.Match<FundProfile>(() => productProfile)
.Exists<FundProfile>( p => enabled, p => RuleViolation(p));
Then()
.Do(_ => productProfile.DisplayError(str));
}
bool RuleViolation(FundProfile pp)
{
if (pp.CountriesListP.Count==0)
return true;
if (pp.CountriesListP.Any(c => c.Allowed))
return false;
else
return true;
}
}
}
As you can see it has external reference
using NRules.Fluent.Dsl;
and some other classes that are up in the hierarchy
using NRule.site.Model;
using NRule.site.Utilities;
When I try the csc command I get this
csc /target:library /out:Mylib.dll AllowAtLeastOneCountryRule.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.34209
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
AllowAtleastOneCountryRule.cs(5,7): error CS0246: The type or namespace name
'NRules' could not be found (are you missing a using directive or an
assembly reference?)
AllowAtleastOneCountryRule.cs(6,18): error CS0234: The type or namespace name
'Model' does not exist in the namespace 'NRule.site' (are you missing a
assembly reference?)
AllowAtleastOneCountryRule.cs(7,18): error CS0234: The type or namespace name
'Utilities' does not exist in the namespace 'NRule.site' (are you
missing an assembly reference?)
AllowAtleastOneCountryRule.cs(11,47): error CS0246: The type or namespace name
'Rule' could not be found (are you missing a using directive or an
assembly reference?)
AllowAtleastOneCountryRule.cs(27,28): error CS0246: The type or namespace name
'FundProfile' could not be found (are you missing a using directive or
an assembly reference?)
How can I reference all the assemblies and compile this class into a DLL?
Any guidance would be great.
You should specify addition assemblies in you command referenced in your code.
csc /target:library reference:assembly_contained_your_types.dll /out:Mylib.dll AllowAtLeastOneCountryRule.cs

The type or namespace name `Dom' does not exist in the namespace `MonoDevelop.Projects'

I'm wading through compiling and install MonoDevelop on Ubuntu 13.10.
It's requiring so many manual compilation of other dependencies, which have found some information online to solve.
Unfortunately, I was not able to solve this one:
The type or namespace name `Dom' does not exist in the namespace `MonoDevelop.Projects'
./configure goes fine, but make gives me the above message, along with the following:
mkdir -p build/
make DEBUG_BeforeBuild
make[3]: Entering directory `/home/leon/dev/monodevelop/extras/JavaBinding'
make[3]: Leaving directory `/home/leon/dev/monodevelop/extras/JavaBinding'
PKG_CONFIG_PATH=../../local-config:$PKG_CONFIG_PATH dmcs -noconfig -codepage:utf8 -warn:4 -optimize- -debug -define:DEBUG -out:build/JavaBinding.dll -target:library './AssemblyInfo.cs' './gtk-gui/generated.cs' './gtk-gui/JavaBinding.CodeGenerationPanelWidget.cs' './gtk-gui/JavaBinding.GlobalOptionsPanelWidget.cs' './Gui/GlobalOptionsPanel.cs' './Gui/ProjectConfigurationPropertyPanel.cs' './IKVMCompilerManager.cs' './JavaCompiler.cs' './JavaLanguageBinding.cs' './Project/JavaCompilerParameters.cs' '-resource:./gtk-gui/gui.stetic' '-resource:./icons/Java.FileIcon' '-resource:./icons/java-16.png' '-resource:./icons/java-22.png' '-resource:./icons/java-icon-32.png' '-resource:./JavaBinding.addin.xml' '-resource:./md1format.xml' '-resource:./templates/EmptyJavaFile.xft.xml' '-resource:./templates/EmptyJavaProject.xpt.xml' '-resource:./templates/IkvmConsoleApplicationProject.xpt.xml' '-resource:./templates/IkvmGladeApplicationProject.xpt.xml' '-resource:./templates/IkvmGnomeApplicationProject.xpt.xml' '-resource:./templates/IkvmGtkApplicationProject.xpt.xml' '-resource:./templates/IkvmLibraryProject.xpt.xml' '-resource:./templates/JavaApplet.xft.xml' '-resource:./templates/JavaApplication.xft.xml' '-resource:./templates/JavaApplicationProject.xpt.xml' '-resource:./templates/JavaConsoleApplicationProject.xpt.xml' '-resource:./templates/JavaDialog.xft.xml' '-resource:./templates/JavaFrame.xft.xml' '-resource:./templates/JavaOKDialog.xft.xml' '-resource:./templates/JavaPanel.xft.xml' -r:Mono.Posix -pkg:glade-sharp-2.0 -pkg:gtk-sharp-2.0 -pkg:mono-addins -pkg:monodevelop -r:System -r:System.Drawing -r:System.Xml
./JavaLanguageBinding.cs(31,28): error CS0234: The type or namespace name `Dom' does not exist in the namespace `MonoDevelop.Projects'. Are you missing an assembly reference?
./JavaLanguageBinding.cs(32,28): error CS0234: The type or namespace name `Dom' does not exist in the namespace `MonoDevelop.Projects'. Are you missing an assembly reference?
./JavaLanguageBinding.cs(34,28): error CS0234: The type or namespace name `CodeGeneration' does not exist in the namespace `MonoDevelop.Projects'. Are you missing an assembly reference?
./JavaLanguageBinding.cs(109,10): error CS0246: The type or namespace name `IParser' could not be found. Are you missing an assembly reference?
./JavaLanguageBinding.cs(113,10): error CS0246: The type or namespace name `IRefactorer' could not be found. Are you missing an assembly reference?
Compilation failed: 5 error(s), 0 warnings
make[2]: *** [build/JavaBinding.dll] Error 1
How do I get these last blocking items installed in order to build successfully?
Disable the "extras/JavaBinding" and "extras/ValaBinding" via './configure --select'. They do not work.

How to rectify Namespace errors in a Windows Store class library in Windows 8 and Visual Studio 2012?

I'm developing a classlibrary(Windows Store Apps) for XMPP in windows 8, I'm Getting these errors, I'd given all the required references like,
System.Net
System.Threading
and so on, But Still these errors arises,
Error 15 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 16 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 17 The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
Error 7 The type or namespace name 'ICloneable' does not exist in the namespace 'System' (are you missing an assembly reference?)
Error 9 The type or namespace name 'IPAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 12 The type or namespace name 'IPAddress' could not be found (are you missing a using directive or an assembly reference?)
Error 13 The type or namespace name 'IPEndPoint' could not be found (are you missing a using directive or an assembly reference?)
Error 6 The type or namespace name 'ListDictionary' could not be found (are you missing a using directive or an assembly reference?)
Error 14 The type or namespace name 'ListDictionary' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 3 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 4 The type or namespace name 'Sockets' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error 5 The type or namespace name 'Stack' could not be found (are you missing a using directive or an assembly reference?)
Error 1 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 8 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 10 The type or namespace name 'Timer' could not be found (are you missing a using directive or an assembly reference?)
Error 18 The type or namespace name 'XmlTextWriter' could not be found (are you missing a using directive or an assembly reference?)
Error 11 Using the generic type 'System.Collections.Generic.Queue' requires 1 type arguments
Please anyone help me or suggest me the solution. . .
/// <summary>
/// returns the Xml, difference to the Xml property is that you can set formatting properties
/// </summary>
/// <param name="format"></param>
/// <param name="indent"></param>
/// <returns></returns>
public string ToString(Formatting format, int indent)
{
return BuildXml(this, format, indent, ' ');
}
#region << Xml Serializer Functions >>
private string BuildXml(Node e, Formatting format, int indent, char indentchar)
{
if ( e != null )
{
System.IO.StringWriter tw = new StringWriter();
XmlTextWriter w = new XmlTextWriter(tw);
w.Formatting = format;
w.Indentation = indent;
w.IndentChar = indentchar;
WriteTree(this, w, null);
return tw.ToString();
}
else
{
return "";
}
}
The 'Formatting' error is coming from this code block, Even though i've given the reference as system.xml
Theres no Option to Resolve,
Based on a quick google search for one of the comments in the code you've provided, I found that it's from here.
As this isn't your own code (I assume - perhaps incorrectly!) that you're attempting to compile for Windows Store Apps which presently targets the 3.5 framework and has references to things such as System.Windows.Forms listed in the project file, it'll likely not work until you rewrite portions of the code to target the Windows Store version of the framework. For example, XmlTextWriter is not listed under the System.Xml namespace in the [.NET For Windows Store Apps] API4.
In short - code for the "full" .net Framework cannot (other than the simplest of snippets) just be recompiled targeting the Windows Store .NET API.

Categories