Clustered Index Entity Framework - azure

When I Create the azure database with Entity Framework model first pattern, then the creation works. But when I want to save the database I get the following error:
"Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again."
I updated entity Framework to Version 6.1.2. But still get the same eroor. Do you have any idea?

Related

Oracle: Why am I getting Error: ORA-00903: invalid table name when database table exists?

Background
I have a NodeJS server powered by ExpressJS that fetches data from Oracle database. I manage the database with Oracle SQL Developer tool. There is a database called MCF01 created using Database Configuration Assistant with pluggable database also named MCF01.
I connect to it using SYSTEM and the admin password both inside Oracle SQL Developer tool and from my server:
Now I created a table named CM_ITM_ALL:
CREATE TABLE "SYS"."CM_ITM_ALL" ...
I can without a problem query inside CM_ITM_ALL from Oracle SQL Developer tool like so:
Problem
I cannot execute the same query SELECT ITM_NM FROM CM_ITM_ALL WHERE ITM_NUM='a800004' using my nodejs server. What is the problem here?
Here is the error message from the Oracle via my server:
[Error: ORA-00942: table or view does not exist] {
errorNum: 942,
offset: 19
}
Table does exist. Connection is not a problem as it is giving out the table does not exist error. Otherwise it would give out wrong credentials error.
What I tried
Appending SYS into the query: SELECT ITM_NM FROM SYS.CM_ITM_ALL WHERE ITM_NUM='a800004'
Quoting the table name inside the query to SELECT ITM_NM FROM 'SYS'.'CM_ITM_ALL' WHERE ITM_NUM='a800004'
Dev environment
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
NodeJS v16.13.0
ExpressJs 4.17.2
node-oracledb 5.3.0
Oracle SQL Developer 21.4.2

azure entity framework issues with error code Unknown error: 0x80070057

I having issues with entity framework on Azure Database, I can open up the models and update the database entities but when I try to run the application the first data call get error Entity Framework is throwing an error “Unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057.”
I'm thinking if I can open the model up and update the entities i have the correct permissions.
I'm not getting the same issues when running localhost with localhost database.
Thanks

Getting SQL Server error while using Hangfire

I am using Hangfire in an ASP.NET MVC5 application to send an email. Until now, it was working fine, but now when I run the application, it is throwing this error:
There is already an object named 'Job' in the database.nstalling Hangfire SQL objects... Database schema [HangFire] already exists Table [HangFire].[Schema] already exists.. Installing schema version 1
From this error, I understood that Hangfire trying to create all those tables in the database which are already there. But I'm not getting reason behind it because till now application was working fine, even when I run it locally many times.
This happened to me and I run this query and restart the server.
Just run the query:
INSERT INTO [HangFire].[Schema]
([Version])
VALUES
(5)
This happened to me when the the sql database user did not have the proper permission in the database (db_datareader, db_ddladmin, db_datawriter, etc).
Adding the proper permission solves it immediately.
I got that problem after export\import the database via .bacpac finished with errors. I removed all my hangfire tables on development database and it worked (careful, do not do that on production DB).
DROP TABLE IF EXISTS HangFire.AggregatedCounter
DROP TABLE IF EXISTS HangFire.Counter
DROP TABLE IF EXISTS HangFire.Hash
DROP TABLE IF EXISTS HangFire.JobParameter
DROP TABLE IF EXISTS HangFire.JobQueue
DROP TABLE IF EXISTS HangFire.List
DROP TABLE IF EXISTS HangFire.[Schema]
DROP TABLE IF EXISTS HangFire.Server
DROP TABLE IF EXISTS HangFire.[Set]
DROP Table IF EXISTS HangFire.State
DROP TABLE IF EXISTS HangFire.Job
My problem was solved by the following Code In Asp Core 2.2:
Startup Class --> ConfigureServices Method:
var cfg = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
services.AddHangfire(x => x
.UseSqlServerStorage(
cfg.GetConnectionString("DefaultConnection"),
new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false
}
));
appsetting.json File:
"ConnectionStrings": {
"DefaultConnection": "Data Source=.;Initial Catalog=databaseName;Persist Security Info=True;User ID=sa;Password=123;MultipleActiveResultSets=True;Application Name=Hang-fire"
},

Enterprise library 5.0 new database

I'm using the enterprise library 5.0 to establish a database connection.
after setting the config file I'm trying to create a new database instance through this line of code :
Database db = DatabaseFactory.CreateDatabase();
but I'm getting this error :
activation error occured while trying to get instance of type database key""
thanks in advance
You need to add the references to it and mark them to be copied locally (see here how to do it: http://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.90).aspx)

SQL Azure unexpected database deletion/recreation

I've been scratching my head on this for hours, but can't seem to figure out what's wrong.
Here's our project basic setup:
MVC 3.0 Project with ASP.NET Membership
Entity Framework 4.3, Code First approach
Local environment: local SQL Server with 2 MDF database files attached (aspnet.mdf + entities.mdf)
Server environment: Windows Azure + 2 SQL Azure databases (aspnet and entities)
Here's what we did:
Created local and remote databases, modified web.config to use SQLEXPRESS connection strings in debug mode and SQL Azure connection strings in release mode
Created a SampleData class extending DropCreateDatabaseAlways<Entities> with a Seed method to seed data.
Used System.Data.Entity.Database.SetInitializer(new Models.SampleData()); in Application_Start to seed data to our databases.
Ran app locally - tables were created and seeded, all OK.
Deployed, ran remote app - tables were created and seeded, all OK.
Added pre-processor directives to stop destroying the Entity database at each application start on our remote Azure environment:
#if DEBUG
System.Data.Entity.Database.SetInitializer(new Models.SampleData());
#else
System.Data.Entity.Database.SetInitializer<Entities>(null);
#endif
Here's where it got ugly
We enabled Migrations using NuGet, with AutomaticMigrationsEnabled = true;
Everything was running smooth and nice. We left it cooking for a couple days
Today, we noticed an unknown bug on the Azure environment:
we have several classes deriving from a superclass SuperClass
the corresponding Entity table stores all of these objects in the same SuperClass table, using a discriminator to know which column to feed from when loading the various classes
While the loading went just fine before today, it doesn't anymore. We get the following error message:
The 'Foo' property on 'SubClass1' could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'.
After a quick check, our SuperClass table has columns Foo and Foo1. Logical enough, since SuperClass has 2 subclasses SubClass1 and SubClass2, each with a Foo property. In our case, Foo is NULL but Foo1 has an int32 value. So the problem is not with the database - rather, it would seem that the link between our Model and Database has been lost. The discriminator logic was corrupted.
Trying to find indications on what could've gone wrong, we noticed several things:
Even though we never performed any migration on the SQL Azure Entity database, the database now has a _MigrationHistory table
The _MigrationHistory table has one record:
MigrationID: 201204102350574_InitialCreate
CreatedOn: 4/10/2012 11:50:57 PM
Model: <Binary data>
ProductVersion: 4.3.1
Looking at other tables, most of them were emptied when this migration happened. Only the tables that were initially seeded with SampleData remained untouched.
Checking in with the SQL Azure Management portal, our Entity database shows the following creation date: 4/10/2012 23:50:55.
Here is our understanding
For some reason, SQL Azure deleted and recreated our database
The _MigrationHistory table was created in the process, registering a starting point to test the model against for future migrations
Here are our Questions
Who / What triggered the database deletion / recreation?
How could EF re-seed our sample data since Application_Start has System.Data.Entity.Database.SetInitializer<Entities>(null);?
EDIT: Looking at what could've gone wrong, we noticed one thing we didn't respect in this SQL Azure tutorial: we didn't remove PersistSecurityInfo from our SQL Azure Entity database connection string after the database was created. Can't see why on Earth it could have caused the problem, but still worth mentioning...
Nevermind, found the cause of our problem. In case anybody wonders: we hadn't made any Azure deployment since the addition of the pre-processor directives. MS must have restarted the machine our VM resided on, and the new VM recreated the database using see data.
Lesson learned: always do frequent Azure deployments.

Resources