This is for an existing database with a View table.
Trying to list a View table, but came across this err msg in my Action:
CREATE DATABASE permission denied in database 'master'.
The view table to access is called: SomeTable
and if you run this on the database (ServerA_dev_alpha_custom):
sp_helptext 'SomeTable'
You’ll get this:
CREATE VIEW dbo.[SomeTable] AS SELECT * FROM ServerA_dev_alpha.dbo.[SomeTable]
Here’s the model:
public class SomeTable
{
[Key]
public virtual string SomeTableid { set; get; }
public virtual string name { set; get; }
public virtual string formvalue { set; get; }
public virtual string status { set; get; }
public virtual DateTime CreateDate { set; get; }
}
The class name:
public class SomeDB: DbContext
Matches exactly to the connection string name:
<add name ="SomeDB"
connectionString ="data source=ServerA\DBSome; integrated Security=SSPI; initial catalog=ServerA_dev_alpha_custom"
providerName="System.Data.SqlClient"/>
The err is found in creating the model:
SomeDB _db = new SomeDB();
var model = (from c in _db.SomeTable
orderby c.CreateDate descending
select c).Take(20);
When i change the connection string to point to where the table is defined: ServerA_dev_alpha (database) it works.
Any ideas?
Even if you’ve an existing database setting the initializer to null works:
Second; forcing a mapping to the table name did the trick: