Visual Studio wants me to save a sql file dbo.Table.sql after I create a Controller for the model that represents the table in my database. The tutorials and documentation that I find online do not mention this at all.
http://www.w3schools.com/aspnet/mvc_models.asp
http://www.asp.net/mvc/overview/getting-started/database-first-development/generating-views
So it opens up a safe dialogue after I specified the Model and Context and press add on the Add Controller dialogue. The path starts in my Documents folder but I am not sure where to safe this, I would logically place this in App_Data.
So why does it ask me to safe the sql file?
And where do I need to store it?
And perhaps, why is this not mentioned in the documentation? I'm pretty sure I am doing it in the same manner. Create SQL Server -> Add tables -> Add Model -> Add MVC5 Controller with views using Entity Framework
The answer is simple, I had a typo in my Model class so it did not find the table, you can see it in the screenshot. If you ask me it would be better to throw a warning when adding a controller that does not have a correctly mapped table and give the option to create a local script file for it. On the other hand, now I know this it's probably obvious.
Related
I want to add a property for a document type in Umbraco. After that, I want to add content using the newly edited document type. Finally, I want to edit the property value of the content and save it into the database. I want to do this using a SQL command in SQL Server Management Studio, given that I have installed Umbraco and I can access the Umbraco database.
You shouldn't do these things directly in the database with Umbraco. In fact, part of your requirements (adding content) wouldn't display on the front end if you did it in the database, as doing so would not fire the events needed to add your new content to the site XML cache.
Ideally you should be doing this in code, using the API. You don't mention which version of Umbraco you're using, so I'll assume the latest (7). That being the case, you ca use the various service APIs to accomplish your requirements. You'd use the ContentType Service to create your new Document Type, and the Content Service to add the content of your new type.
For more information, refer to the Umbraco services reference page: here
As Tim says it's not a good idea to do this with SQL, an alternative solution is to do it with a package. An Umbraco package contains an XML document, it is also possible there to make an adjustment in the XML (if the goal is a generated change)
I am using CoreData for my Project.
In first image i selected Site to create the entity object.
After clicking the next. If you see the second image, Game files are created.
Here i want to create entity object for Site, But it is creating Game entity object. Please help me out.
Make sure the class name in the right hand panel is what you want it to be. You can also access this in the configuration editor for the Default configuration.
Right side panel
Configuration
I have an ASP.net MVC 4 project I am working on and am trying to add an ADO.net EF model to it using Database First.
The creation of the model (.edmx file) seems to run successfully and I am left with the desired .edmx model file in the folder I specified. However, I don't appear to be able to see any of the files nested under this model. (From all my research, I should be able to expand the .edmx file and see *Context.vb, *Designer.vb, *.edmx.diagram and *.tt files underneath, but I cannot.)
It should look something like this in the msdn article about Database First (see Step 4):
Upon noticing this issue, I discovered a handful of warnings that appeared after creating the .edmx model, one of which is (I have obscured part of the full path):
The path 'P:\IT\...\DAL\EF.Utility.VB.ttinclude' must be either local to this computer or part of your trusted zone. If you have downloaded this template, you may need to 'Unblock' it using the properties page for the template file in File Explorer.
The project is stored on a network share on one of our servers so it can be included in our daily backups and Windows Shadow copy also. My understanding is that the above warning has appeared because of this and I need to set my machine to trust this location.
I have tried all possible variations I can think of of
this MSDN article
but to absolutely not success at all, the warning remains.
Either I am looking in the wrong place, or I have missed something.
Does anyone know what I can do to remove this warning and gain access to the objects nested below the .edmx model?
Perhaps this could be of some assistance. I've never really dealt with trust issues working across the domain. I lean towards pulling down and working with a local copy.
This may just be a yes or no type of question but here goes anyway...
From all (well most) of the examples that I've seen for using mvc, it appears that method for creating the dbml file is just drop the entire schema of the database into it and let it autogenerate all of the linq to sql goodness. It appears that you just need one of these (as you can't have duplicate tables in separate dbml files in the same project) but for some reason it would seem like there's a better way to do this...especially when dealing with a large project that has a fair number of tables.
So is this the proper way to go about creating a dbml file to use in a mvc project, just drop the entire table structure into and go to town? If not, how do you do it?
If the schema was large, I think i would be relying fully on a SQLMetal script to generate my *.dbml and backing classes. This way you can just regenerate your entire data model whenever your database gets updated. Otherwise, if a table, view, etc, gets updated in the database you don't have to delete and then re drag-and-drop that table into your visual *.dbml file.
Actually, I am not expert with SQLMetal, but I think you can even use it it to generate everything you need for Linq-toSql and not even require/generate a *.dbml file.
I'm not sure yet - its a problem I'm still working on but I think that the answer is that should it be desirable to have multiple dbml files - effectively views of your data - then you want to host the dbml files in their own projects so that you can have the similar things in multiple namespaces and not have them conflict.
This being the case the next logical step is to put your dbml files/models into their own projects by default and to learn to work with them when set up that way. This will also aid reuse of a model of database where you have more than one application interacting with that database.
There are certainly issues with separating the thing out and also with having multiple dbml files in a a single project (in terms of ensuring that extensions to the classes are implemented conistently in all instances for example) but I've got a case where its not inappropriate.
Good question, answer probably tends towards being "just one" but not in every case...
Personally I prefer to create the classes/association in the .dbml and then generate the database from that.
Just add the following class to your project
partial class MyDataContext {
partial void OnCreated() {
if (!DatabaseExists())
CreateDatabase();
}
}
So I would like it when a user creates a new folder in my sharepoint document library that 4 template documents also get added inside the new folder. I get that the user could just click on the document template for each template individual but I want them added all the time.
There doesn't seem to be an option to add template documents to a document lib folder content type.
Sooo.... Is my only alternative to create a custom sharepoint workflow that checks for the folder creation inside my doc lib. (Ideally maybe restricting it to only when a specific folder of my custom content type is created.. ) This seems like a simple workflow to create but I want to make sure that I even need to create one since I haven't actually created a custom sharepoint workflow yet...
Thanks,
Chris
You're right; there's no built-in functionality for this. It should be reasonable simple to write a workflow that runs when something is added to a library, checks to see if it is a folder, and adds the items into the folder. It would probably be easiest to have the template documents in another folder somewhere, and then copy them over.
Good luck!
I found this example that helped out a lot:
http://www.codeproject.com/KB/sharepoint/MOSS_FolderContentTypeWF.aspx