identity
column in that table by using the following code:ALTER TABLE dbo.tablename ADD AUTOID INT IDENTITY(1,1)
identity
column in that table by using the following code:
SELECT col1, col2, col3=count(*)
INTO holdkey
FROM t1
GROUP BY col1, col2
HAVING count(*) > 1
Select the duplicate rows into a holding table, eliminating duplicates in the process. For example: SELECT DISTINCT t1.* INTO holddups FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: SELECT col1, col2, count(*) FROM holddups GROUP BY col1, col2 should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.
Delete the duplicate rows from the original table. For example: DELETE t1 FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
Put the unique rows back in the original table. For example: INSERT t1 SELECT * FROM holddups
MyProject.Controllers.CurrencyCodesController Unable to update the EntitySet 'CurrencyCodes' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. System.Data.Entity.Infrastructure.DbUpdateException: Unable to update the EntitySet 'CurrencyCodes' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. ---> System.Data.Entity.Core.UpdateException: Unable to update the EntitySet 'CurrencyCodes' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. |
Scenario: The error occured while trying to insert the currencycodes entity to the database. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "cucCurrencyCode,cucDescription,cucMultiplier,cucRate,cucInUse")] CurrencyCode currencyCode) { if (ModelState.IsValid) { try { db.CurrencyCodes.Add(currencyCode); db.SaveChanges(); } catch (Exception ex) { log.Error(ex.Message, ex); } return RedirectToAction("Index"); } return View(currencyCode); } 1) Check Primary key in .edmx file. In my case cucInUse was set as Entity key. I removed it. 2) Now Right click the .edmx file and click "Open with...". Select XML (text) Editor 3) Find the element <EntitySet name = "CurrencyCodes"...> 4) Change store:Schema="dbo" => Schema="dbo" 5) delete element <DefiningQuery> 6) Clean the project. 7) close Visual studio. 8) Open visual studio. Open the project. 9) Clean and build the project. 10) Run the application. |
a) open the ssis package in visual studio.
b) In the Control flow tab, right click on the blank space of the canvas.
c) go to Package Configurations...
d) uncheck Enable Package Configuartion and press Close.
e) Save the ssis package and copy that to the deployed folder.
void Application_Start(object sender, EventArgs e) { // link up log4net configuration log4net.Config.XmlConfigurator.Configure(); }
log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log.Error("An unhandled exception occured", ex);
void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs // get last exception Exception ex = Server.GetLastError().GetBaseException(); // log it log.Error("An unhandled exception occured", ex); }
<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections>
<log4net> <!-- The DebugFileAppender writes all messages to a log file--> <appender name="DebugFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="L:\[APPNAME]\Log.txt" /> <!-- These should be located on the "L" drive (if available) and stored under a folder named for the specific application --> <datePattern value="'ApplicationLog.'yyyy-MM-dd'.txt'" /> <staticLogFileName value="false" /> <rollingStyle value="Composite" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="5MB" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d [%t] %-5p %c %m%n" /> </layout> </appender> <!-- The EmailAppender sends an email when something matches the filters--> <appender name="EmailAppender" type="log4net.Appender.SmtpAppender"> <evaluator type="log4net.Core.LevelEvaluator"> <threshold value="DEBUG"/> </evaluator> <!-- The filters are processed in order: 1) match the Inserted New User message 2) match any WARN or higher messages 3) reject everything else --> <filter type="log4net.Filter.StringMatchFilter"> <stringToMatch value="Inserted a new user" /> <acceptOnMatch value="true" /> </filter> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="WARN" /> <acceptOnMatch value="true" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> <!-- The SmtpAppender authenticates against the mail server, the buffersize of 10 provides 10 lines of context when an error happens. --> <subject value="[SEVERITY] [ENV] [APPNAME] - [EXCP_MSG]" /> <to value="itteam@site.com" /> <from value="noreply@site.com" /> <smtpHost value="smtpmail.lu.sii.com" /> <bufferSize value="10" /> <lossy value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" /> </layout> </appender><appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<applicationName value="MyApp" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <root> <!-- add other appenders here and the log messages will be sent to every listed appender --> <appender-ref ref="DebugFileAppender" /> <appender-ref ref="EmailAppender" /> </root> </log4net>
To SSH connect to a linux machine, a raspberry pi in my example from a PC without using a username and password, you can set up SSH key-b...