Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Created Issue: Possibility to have generate views also [605]

$
0
0
It would be nice to EF be able to define a View and not only tables.
To do that, right now I have a table and will be droped in the Seed method of the configuration and a view with the same name will be created.

context.Database.ExecuteSqlCommand("IF EXISTS (SELECT * FROM sys.tables WHERE object_id = OBJECT_ID(N'[dbo].[vwUserTypes]')) DROP TABLE [dbo].[vwUserTypes]");
context.Database.ExecuteSqlCommand(@"CREATE VIEW [dbo].[vwUserTypes] AS SELECT TOP (100) PERCENT ReferenceId AS UserTypeId, ReferenceValue AS UserType FROM dbo.tblSystemReferences WHERE (ReferenceTable = 'UserType') AND (IsActive = 1) ORDER BY UserTypeID");

Doing this will work fine but if I want to create a relation between this view and tblUser table the system said that cannot create the FK in the view.

What I expect it's possible to mark my domain object to be serializes as a view and somewhere and somehow I could create a linq query to define my view or even SQL Statement like I do now in my example.
In the end, if I want to link a object to this View, the EF will not create a FK in the View.

is the future, base on a method would be nice to generate the store procedure code too ... but that's another story.

Regards
Paulo Aboim Pinto
Odivelas - Portugal

Viewing all articles
Browse latest Browse all 10318

Trending Articles